Assignment List For Python
Assignment List For Python
5. Write a Python program to count the number of strings where the string length
is 2 or more and the first and last character are same from a given list of strings.
Sample List : ['abc', 'xyz', 'aba', '1221']
Expected Result : 2
6. Write a Python program to get a list, sorted in increasing order by the last
element in each tuple from a given list of non-empty tuples.
Sample List : [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
Expected Result : [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]
10. Write a Python program to find the list of words that are longer than n from a
given list of words.
11. Write a Python function that takes two lists and returns True if they have at
least one common member.
12. Write a Python program to print a specified list after removing the 0th, 4th
and 5th elements.
Sample List : ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
Expected Output : ['Green', 'White', 'Black']
14. Write a Python program to print the numbers of a specified list after removing
even numbers from it.
16. Write a Python program to generate and print a list of first and last 5
elements where the values are square of numbers between 1 and 30 (both
included).
17. Write a Python program to generate and print a list except for the first 5
elements, where the values are square of numbers between 1 and 30 (both
included).
19. Write a Python program to get the difference between the two lists.
26. Write a python program to check whether two lists are circularly identical.
38. Write a Python program to change the position of every n-th value with the
(n+1)th in a list.
Sample list: [0,1,2,3,4,5]
Expected Output: [1, 0, 3, 2, 5, 4]
42. Write a Python program to find missing and additional values in two lists.
Sample data : Missing values in second list: b,a,c
Additional values in second list: g,h
48. Write a Python program to print a nested lists (each list on a new line) using
the print() function.
58. Write a Python program to replace the last element in a list with another list.
Sample data : [1, 3, 5, 7, 9, 10], [2, 4, 6, 8]
Expected Output: [1, 3, 5, 7, 9, 2, 4, 6, 8]
59. Write a Python program to check if the n-th element exists in a given list.
60. Write a Python program to find a tuple, the smallest second index value from
a list of tuples.
63. Write a Python program to insert a given string at the beginning of all items in
a list.
Sample list : [1,2,3,4], string : emp
Expected output : ['emp1', 'emp2', 'emp3', 'emp4']
66. Write a Python program to find the list in a list of lists whose sum of elements
is the highest.
Sample lists: [1,2,3], [4,5,6], [10,11,12], [7,8,9]
Expected Output: [10, 11, 12]
67. Write a Python program to find all the values in a list are greater than a
specified number.