Assignment 3
Assignment 3
S.N Roll
Name of the Student Problem
O Number
Given a list, write a Python program
to swap first and last element of the
list.
Examples:
1. 22AD001 AKILAN A Input : [12, 35, 9, 56, 24]
Output : [24, 35, 9, 56, 12]
Input : [1, 2, 3]
Output : [3, 2, 1]
Examples:
2. 22AD002 AKSHAYA S Input : List = [23, 65, 19, 90], pos1 =
1, pos2 = 3
Output : [19, 65, 23, 90]
Input:amaama
Output:
The entered string is symmetrical
The entered string is palindrome
Output : 1, 22
Input: 5 5
Output: 5
17. 22AD017 HARSHINI S.G Given a list, the task is to sort the
list according to the column using
the lambda approach.
Examples:
Input :
array = [[1, 3, 3], [2, 1, 2], [3, 2, 1]]
Output :
Sorted array specific to column 0,
[[1, 3, 3], [2, 1, 2], [3, 2, 1]]
Sorted array specific to column 1,
[[2, 1, 2], [3, 2, 1], [1, 3, 3]]
Sorted array specific to column 2,
[[3, 2, 1], [2, 1, 2], [1, 3, 3]]
Input :
array = [[‘java’, 1995], [‘c++’, 1983],
[‘python’, 1989]]
Output :
Sorted array specific to column 0,
[[‘c++’, 1983], [‘java’, 1995],
[‘python’, 1989]]
Sorted array specific to column 1,
[[‘c++’, 1983], [‘python’, 1989],
[‘java’, 1995]]
Input : [1, 1, 1, 5, 5, 3, 1, 3, 3, 1,
4, 4, 4, 2, 2, 2, 2]
Output : 1 : 5
2:4
3:3
4:3
5:2
Explanation : Here 1 occurs 5 times,
2
occurs 4 times and so on...
Input : s1 = Hello
: s2 = dnaKfhelddf
Output : Not Possible
38. 22AD038 RAGUNATH M Sometimes, while working with
Python records, we can have a
problem in which we need to find
the tuple nearest to certain tuple,
query on a particular index. This
kind of problem can have
application in data domains such as
web development.
Input :
test_list = [(3, 4), (78, 76), (2, 3), (9,
8), (19, 23)]
tup = (17, 23)
K=2
Output : (19, 23)
Input :
test_list = [(3, 4, 9), (5, 6, 7)]
tup = (1, 2, 5)
K=3
Output : (5, 6, 7)
Input : a = 4, b = 5
Output : No
Input:
cars bikes arcs steer
Output: 2