List 1 Practice
List 1 Practice
7. Write a Python program to remove duplicates from a list. Use another list to store unique values.
11. Write a Python program which has two lists and returns True if they have at least one common
member.
14. Write a Python program to print the numbers of a gven list after removing even numbers from it.
Ex. l1=[10,25,45,78,90,103,455]
o/p :: [25,45,103,455]
17. Write a Python program to check if each number is prime in a given list of numbers. Return True if all
numbers are prime otherwise False.
Sample Data:
ex.
l1=[1,4,7,8]
l2=[2,5,7,23]
explaination:
22. Write a Python program to find the index of an item in a specified list.
23. Write a Python program to flatten a simple list.
24. Write a Python program to append all elements from a list to the second list.
25. Write a Python program to select an item randomly from a list. ( use randint function from random
library)
26. Write a Python program to check whether two lists are circularly identical.
Ex.
l1=[1,2,3,4]
l2=[2,3,4,1]
l3=[4,1,2,3]
l4=[3,4,1,2]
30. Write a Python program to get the frequency of every element in a list.
31. Write a Python program to count the number of elements in a list within a specified slice ( range) of
start and end index.
32. Write a Python program to check whether a list contains a sublist. ( all elements from one list are
present in other list)
Ex.
l1=[5,7,9,12]
l2=[7,9]
l3=[12,7]
l3 is sublist of l1
36. Write a Python program to make list of all digits from given number
37. Write a Python program to find common items in two lists.
38. Write a Python program to change the position of every two consecutive elements n-th value to the
(n+1)th in a list. ( swap nth and n+1 th value)
0 -1 , 2-3 , 4-5
39. Write a Python program to convert a list of multiple integers into a single integer.
ex2: l1=[8,9,0]
output : 890
41. Write a Python program to check if given list contains another list object or not.
Ex. l1=[10,20,30]
l2=[10,20,[45,67]]
43. Write a Python program to split a list into different variables from center.
Ex.
l1=[12,23,34,45,56,67]
first=[12,23,34]
second=[45,56,67]
l2=[12,23,34,45,56,67,99]
first=[12,23,34]
second=[45,56,67,99]
44. Write a Python program to generate groups of three consecutive numbers in a list.
l1=[1,2,3,4,5,6,7,8,9,10]
Ans
45. Write a Python program to take a list. Find all unique values. Then print all unique values in sorted
order.
Ex. l1=[1,2,3]
o/p [10,1,10,2,10,3]
54. Write a Python program to concatenate elements of a given list to another list.
59. Write a Python program to check whether the n-th element exists in a given list. Dont give error if n is
out of bounds, print out of bounds message.
Ex.
l1=[90,98,87,76,65]
ex.
l1=[2,4,7]
l2=[12,45,67]
output:
2 12
4 45
7 67
65. Write a Python program to move all zero digits to the end of a given list of numbers.
Original list:
[3, 4, 0, 0, 0, 6, 2, 0, 6, 7, 6, 0, 0, 0, 9, 10, 7, 4, 4, 5, 3, 0, 0, 2, 9, 7, 1]
Expected output:
[3, 4, 6, 2, 6, 7, 6, 9, 10, 7, 4, 4, 5, 3, 2, 9, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
5. Write a Python program to count the number of strings from a given list of strings.
Condition is, the string length is 2 or more and the first and last characters are the same.
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)]
7. Write a Python program to remove duplicates from a list. Use another list to store unique values.
11. Write a Python program which has 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.
13. Write a Python program to generate a 3*4*6 3D array whose each element is *.
14. Write a Python program to print the numbers of a gven list after removing even numbers from it.
Ex. l1=[10,25,45,78,90,103,455]
o/p :: [25,45,103,455]
16. Write a Python program to generate and print a list of the first and last 5 elements where the values
are square numbers between 1 and 30 (both included).
17. Write a Python program to check if each number is prime in a given list of numbers. Return True if all
numbers are prime otherwise False.
Sample Data:
19. Write a Python program to calculate the difference between the two lists.
ex.
l1=[1,4,7,8]
l2=[2,5,7,23]
explaination:
22. Write a Python program to find the index of an item in a specified list.
23. Write a Python program to flatten a simple list.
24. Write a Python program to append all elements from a list to the second list.
25. Write a Python program to select an item randomly from a list. ( use randint function from random
library)
26. Write a Python program to check whether two lists are circularly identical.
Ex.
l1=[1,2,3,4]
l2=[2,3,4,1]
l3=[4,1,2,3]
l4=[3,4,1,2]
27. Write a Python program to find the second smallest number in a list.
28. Write a Python program to find the second largest number in a list.
30. Write a Python program to get the frequency of every element in a list.
31. Write a Python program to count the number of elements in a list within a specified slice ( range) of
start and end index.
32. Write a Python program to check whether a list contains a sublist. ( all elements from one list are
present in other list)
Ex.
l1=[5,7,9,12]
l2=[7,9]
l3=[12,7]
l3 is sublist of l1
**34. Write a Python program that uses the Sieve of Eratosthenes method to compute prime numbers up
to a specified number.
Note: In mathematics, the sieve of Eratosthenes, (Ancient Greek: κόσκινον Ἐρατοσθένους, kóskinon
Eratosthénous) one of a number of prime number sieves, is a simple, ancient algorithm for finding all
prime numbers up to any given limit.
35. Write a Python program to create a list by concatenating a given list with a range from 1 to n.
n =5
Sample Output : ['p1', 'q1', 'p2', 'q2', 'p3', 'q3', 'p4', 'q4', 'p5', 'q5']
36. Write a Python program to make list of all digits from given number
38. Write a Python program to change the position of every two consecutive elements n-th value to the
(n+1)th in a list. ( swap nth and n+1 th value)
0 -1 , 2-3 , 4-5
39. Write a Python program to convert a list of multiple integers into a single integer.
ex2: l1=[8,9,0]
output : 890
40. Write a Python program to split a list of words based on the first character of a word.
if first character is vowel then put that word in l1 else put that word in l2.
Ex.
words=['abc','xyz','op','qwe']
l1=['abc','op']
l2=['xyz','qwe']
41. Write a Python program to check if given list contains another list object or not.
Ex. l1=[10,20,30]
l2=[10,20,[45,67]]
42. Write a Python program to find missing and additional values in two lists.
Sample data :
first=['b','a','c','d','e','f']
second=['d','e','f','g','h']
43. Write a Python program to split a list into different variables from center.
Ex.
l1=[12,23,34,45,56,67]
first=[12,23,34]
second=[45,56,67]
l2=[12,23,34,45,56,67,99]
first=[12,23,34]
second=[45,56,67,99]
44. Write a Python program to generate groups of three consecutive numbers in a list.
l1=[1,2,3,4,5,6,7,8,9,10]
Ans
45. Write a Python program to take a list. Find all unique values. Then print all unique values in sorted
order.
46. Write a Python program to select the odd elements from a list into new list.
47. Write a Python program to insert an element before each element of a list.
Ex. l1=[1,2,3]
o/p [10,1,10,2,10,3]
48. Write a Python program to print nested lists (each list on a new line) using the print() function.
l1=[[1,2,3],[4,5,6],[7,8]]
[1,2,3]
[4,5,6]
[7,8]
**49. Write a Python program to convert a list to a list of dictionaries. ( Hint: this is part of creating
dictionaries)
Sample lists: ["Black", "Red", "Maroon", "Yellow"], ["#000000", "#FF0000", "#800000", "#FFFF00"]
Sample list:
l1=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n']
n=5
Expected Output: [['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]
52. Write a Python program to compute the difference between two lists.
Sample data:
Expected Output:
In color1, white, red and orange colors are there which are extra than color2
In color2, black and yellow colors are there which are extra than color2
**53. Write a Python program to create a list with infinite elements.(this is part of generator function)
54. Write a Python program to concatenate elements of a given list to another list.
**55. Write a Python program to remove key-value pairs from a list of dictionaries.
57. Write a Python program to count how many times a word comes in given list of words.
Ex
word = "cdac"
word_list=["cadc","cdac","iop","lkjh","cdac"]
58. Write a Python program to replace the last element in a list with another list.
59. Write a Python program to check whether the n-th element exists in a given list. Dont give error if n is
out of bounds, print out of bounds message.
Ex.
l1=[90,98,87,76,65]
**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.
ex.
l1=[2,4,7]
l2=[12,45,67]
output:
2 12
4 45
7 67
65. Write a Python program to move all zero digits to the end of a given list of numbers.
Original list:
[3, 4, 0, 0, 0, 6, 2, 0, 6, 7, 6, 0, 0, 0, 9, 10, 7, 4, 4, 5, 3, 0, 0, 2, 9, 7, 1]
Expected output:
[3, 4, 6, 2, 6, 7, 6, 9, 10, 7, 4, 4, 5, 3, 2, 9, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
66. Write a Python program to find the list in a list of lists whose sum of elements is the highest.
Sample list:
67. Write a Python program to find all the values in a list that are greater than a specified number.
Sample data:
Sample list : [[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]
70. Write a Python program to find items starting with a specific character from a list.
Example:
Original list:
['dagfa']
[]
**71. Write a Python program to check whether all dictionaries in a list are empty or not.
Original list: [0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]
Flatten list:
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
73. Write a Python program to remove consecutive (following each other continuously) duplicates
(elements) from a given list.
Original list:
[0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]
74. Write a Python program to pack consecutive duplicates of a given list of elements into sublists.
Original list:
[0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]
After packing consecutive duplicates of the said list elements into sublists:
[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]
75. Write a Python program to create a list reflecting the run-length encoding from a given list of integers
or a given list of characters.
Original list:
[1, 1, 2, 3, 4, 4.3, 5, 1]
[[2, 1], [1, 2], [1, 3], [1, 4], [1, 4.3], [1, 5], [1, 1]]
Original list:
['a','u','t','o','m','a','t','i','c','a','l','l','y']
[[1, 'a'], [1, 'u'], [1, 't'], [1, 'o'], [1, 'm'], [1, 'a'], [1, 't'], [1, 'i'], [1, 'c'], [1, 'a'], [2, 'l'], [1, 'y']]
76. Write a Python program to create a list reflecting the modified run-length encoding from a given list of
integers or a given list of characters.
Original list:
[1, 1, 2, 3, 4, 4, 5, 1]
List reflecting the modified run-length encoding from the said list:
Original String:
aabcddddadnss
List reflecting the modified run-length encoding from the said string:
[[2, 'a'], 'b', 'c', [4, 'd'], 'a', 'd', 'n', [2, 's']]
77. Write a Python program to decode a run-length message.
[1, 1, 2, 3, 4, 4, 5, 1]
78. Write a Python program to split a given list into two parts where the length of the first part of the list
is given.
Original list:
[1, 1, 2, 3, 4, 4, 5, 1]
79. Write a Python program to remove the K'th element from a given list, and print the updated list.
Original list:
[1, 1, 2, 3, 4, 4, 5, 1]
[1, 1, 3, 4, 4, 5, 1]
80. Write a Python program to insert an element at a specified position into a given list.
Original list:
[1, 1, 2, 3, 4, 4, 5, 1]
After inserting an element at kth position in the said list:
[1, 1, 12, 2, 3, 4, 4, 5, 1]
81. Write a Python program to extract a given number of randomly selected elements from a given list.
Original list:
[1, 1, 2, 3, 4, 4, 5, 1]
[4, 4, 1]
82. Write a Python program to generate combinations of n distinct objects taken from the elements of a
given list.
Original list: [1, 2, 3, 4, 5, 6, 7, 8, 9] Combinations of 2 distinct objects: [1, 2] [1, 3] [1, 4] [1, 5] .... [7, 8] [7,
9] [8, 9]
83. Write a Python program to round every number in a given list of numbers and print the total sum
multiplied by the length of the list.
Original list: [22.4, 4.0, -16.22, -9.1, 11.0, -12.22, 14.2, -5.2, 17.5]
Result:
243
84. Write a Python program to round the numbers in a given list, print the minimum and maximum
numbers and multiply the numbers by 5. Print the unique numbers in ascending order separated by
space.
Original list: [22.4, 4.0, 16.22, 9.1, 11.0, 12.22, 14.2, 5.2, 17.5]
Minimum value: 4
Maximum value: 22
Result:
20 25 45 55 60 70 80 90 110
85. Write a Python program to create a multidimensional list (lists of lists) with zeros.
87. Write a Python program to read a matrix from the console and print the sum for each column. As
input from the user, accept matrix rows, columns, and elements separated by a space (each row).
Input rows: 2
Input columns: 2
12
34
46
88. Write a Python program to read a square matrix from the console and print the sum of the matrix's
primary diagonal. Accept the size of the square matrix and elements for each column separated with a
space (for every row) as input from the user.
456
347
14
Original lists:
Zipped list:
90. Write a Python program to count the number of lists in a given list of lists.
Original list:
Original list:
91. Write a Python program to find a list with maximum and minimum lengths.
Original list:
[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]
(1, [0])
Original list:
(1, [0])
Original list:
[[12], [1, 3], [1, 34, 5, 7], [9, 11], [3, 5, 7]]
(1, [12])
92. Write a Python program to check if a nested list is a subset of another nested list.
Original list:
True
Original list:
True
Original list:
False
93. Write a Python program to count the number of sublists that contain a particular element.
Original list:
Original list:
[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']]
94. Write a Python program to count the number of unique sublists within a given list.
Original list:
[[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]]
Original list:
95. Write a Python program to sort each sublist of strings in a given list of lists.
Original list:
[[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]]
[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]
96. Write a Python program to sort a given list of lists by length and value.
Original list:
[[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]]
[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]
97. Write a Python program to remove sublists from a given list of lists that contain an element outside a
given range.
Original list:
[[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]]
After removing sublists from a given list of lists, which contains an element outside the given range:
Original list:
99. Write a Python program to find the maximum and minimum values in a given heterogeneous list.
Original list:
['Python', 3, 2, 4, 5, 'version']
(5, 2)
100. Write a Python program to extract common index elements from more than one given list.
Original lists:
[1, 1, 3, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 5, 7]
[0, 1, 2, 3, 4, 5, 7]
[1, 7]
101. Write a Python program to sort a given matrix in ascending order according to the sum of its rows.
Original Matrix:
Sort the said matrix in ascending order according to the sum of its rows
[[1, 1, 1], [1, 2, 3], [2, 4, 5]]
Original Matrix:
Sort the said matrix in ascending order according to the sum of its rows
102. Write a Python program to extract specified size of strings from a give list of string values.
Original list:
['practice', 'solution']
103. Write a Python program to extract specified number of elements from a given list, which follows
each other continuously.
Original list:
[1, 1, 3, 4, 4, 5, 6, 7]
Extract 2 number of elements from the said list which follows each other continuously:
[1, 4]
Original lists:
[0, 1, 2, 3, 4, 4, 4, 4, 5, 7]
Extract 4 number of elements from the said list which follows each other continuously:
[4]
104. Write a Python program to find the difference between consecutive numbers in a given list.
Original list:
[1, 1, 3, 4, 4, 5, 6, 7]
[0, 2, 1, 0, 1, 1, 1]
Original list:
[4, 5, 8, 9, 6, 10]
[1, 3, 1, -3, 4]
Original list:
[1, 1, 3, 4, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 4, 5, 7, 8]
3.823529411764706
Original list:
107. Write a Python program to remove a specified column from a given nested list.
108. Write a Python program to extract a specified column from a given nested list.
[1, 2, 1]
[3, -5, 1]
109. Write a Python program to rotate a given list by a specified number of items in the right or left
direction.
original List:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]
[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]
Rotate the said list in Right direction by 4:
[8, 9, 10, 1, 2, 3, 4, 5, 6]
[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]
110. Write a Python program to find the item with the most occurrences in a given list.
Original list:
[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2]
111. Write a Python program to access multiple elements at a specified index from a given list.
Original list:
[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2]
Index list:
[0, 3, 5, 7, 10]
[2, 4, 9, 2, 1]
112. Write a Python program to check whether a specified list is sorted or not.
Original list:
True
Original list:
[1, 2, 4, 6, 8, 10, 12, 14, 16, 17]
False
113. Write a Python program to remove duplicate dictionary entries from a given list.
114. Write a Python program to extract the nth element from a given list of tuples.
Original list:
[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)]
115. Write a Python program to check if the elements of a given list are unique or not.
Original list:
False
Original list:
True
116. Write a Python program to sort a list of lists by a given index of the inner list.
Original list:
[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)]
Sort the said list of lists by a given index ( Index = 0 ) of the inner list
[('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99), ('Wyatt Knott', 91, 94)]
Sort the said list of lists by a given index ( Index = 2 ) of the inner list
[('Wyatt Knott', 91, 94), ('Brady Kent', 97, 96), ('Beau Turnbull', 94, 98), ('Greyson Fulton', 98, 99)]
117. Write a Python program to remove all elements from a given list that are present in another list.
Original lists:
list2: [2, 4, 6, 8]
[1, 3, 5, 7, 9, 10]
118. Write a Python program to find the difference between elements (n+1th - nth) of a given list of
numeric values.
Original list:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 1, 1, 1, 1, 1, 1, 1, 1]
Original list:
[2, 4, 6, 8]
[2, 2, 2]
119. Write a Python program to check if a substring appears in a given list of string values.
Original list:
Substring to search:
ack
True
Substring to search:
abc
False
120. Write a Python program to create a list taking alternate elements from a given list.
Original list:
Original list:
[2, 0, 3, 4, 0, 2, 8, 3, 4, 2]
[2, 3, 0, 8, 4]
121. Write a Python program to find nested list elements that are present in another list.
Original lists:
[[12, 18, 23, 25, 45], [7, 11, 19, 24, 28], [1, 5, 8, 18, 15, 16]]
Original lists:
[[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]
[18, 12]
123. Write a Python program to reverse strings in a given list of string values.
Original lists:
124. Write a Python program to find the maximum and minimum product of pairs of tuples within a given
list.
Maximum and minimum product from the pairs of the said tuple of list:
(36, 8)
125. Write a Python program to calculate the product of the unique numbers in a given list.
Original List : [10, 20, 30, 40, 20, 50, 60, 40]
126. Write a Python program to interleave multiple lists of the same length.
Original list:
list1: [1, 2, 3, 4, 5, 6, 7]
[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]
127. Write a Python program to remove words from a given list of strings containing a character or string.
Original list:
Character list:
New list:
128. Write a Python program to calculate the sum of the numbers in a list between the indices of a
specified range.
Original list:
Range: 8 , 10
29
129. Write a Python program to reverse each list in a given list of lists.
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]
130. Write a Python program to count the same pair in three given lists.
Original lists:
[1, 2, 3, 4, 5, 6, 7, 8]
[2, 2, 3, 1, 2, 6, 7, 9]
[2, 1, 3, 1, 2, 6, 7, 9]
131. Write a Python program to count the frequency of consecutive duplicate elements in a given list of
numbers.
Original lists:
[1, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5]
132. Write a Python program to find all index positions of the maximum and minimum values in a given
list of numbers.
Original list:
[12, 33, 23, 10, 67, 89, 45, 667, 23, 12, 11, 10, 54]
3, 11
133. Write a Python program to check if two lists have the same elements in them in same order or not.
Original lists:
Test common elements between color1 and color2 are in same order?
True
Test common elements between color1 and color3 are in same order?
False
Test common elements between color2 and color3 are in same order?
False
134. Write a Python program to find the difference between two lists including duplicate elements.
Original lists:
[1, 1, 2, 3, 3, 4, 4, 5, 6, 7]
[1, 1, 2, 4, 5, 6]
[3, 3, 4, 7]
135. Write a Python program to iterate over all pairs of consecutive items in a given list.
Original lists:
[1, 1, 2, 3, 3, 4, 4, 5]
[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]
136. Write a Python program to remove duplicate words from a given list of strings.
Original String:
137. Write a Python program to find the first even and odd number in a given list of numbers.
Original list:
[1, 3, 5, 7, 4, 1, 6, 8]
(4, 1)
138. Write a Python program to sort a given mixed list of integers and strings. Numbers must be sorted
before strings.
Original list:
Original list:
140. Write a Python program to remove a specific item from a given list of lists.
Original list:
[[], [], [], 'Red', 'Green', [1, 2], 'Blue', [], []]
After deleting the empty lists from the said lists of lists
142. Write a Python program to sum a specific column of a list in a given list of lists.
12
15
143. Write a Python program to get the frequency of elements in a given list of lists.
{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}
144. Write a Python program to extract every first or specified element from a given two-dimensional list.
Extract every first element from the said given two dimensional list:
[1, 4, 7]
Extract every third element from the said given two dimensional list:
[3, 6, 9]
145. Write a Python program to generate a number in a specified range except for some specific numbers.
-4
146. Write a Python program to compute the sum of digits of each number in a given list.
Original tuple:
[10, 2, 56]
14
Original tuple:
19
Original tuple:
19
147. Write a Python program to combine two lists into another list randomly.
Original lists:
[1, 2, 7, 8, 3, 7]
[4, 3, 8, 9, 4, 3, 8, 9]
[4, 1, 2, 3, 8, 9, 4, 3, 7, 8, 9, 8, 3, 7]
148. Write a Python program to remove specific words from a given list.
Original list:
Remove words:
['white', 'orange']
149. Write a Python program to get all possible combinations of the elements of a given list.
Original list:
[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'],
['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'],
['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]
Original list:
151. Write a Python program to find the maximum and minimum values in a given list within a specified
index range.
Original list:
[4, 3, 0, 5, 3, 0, 2, 3, 4, 2, 4, 3, 5]
Index range:
3 to 8
Maximum and minimum values of the said given list within index range:
(5, 0)
152. Write a Python program to combine two sorted lists using the heapq module.
[1, 3, 5, 7, 9, 11]
[0, 2, 4, 6, 8, 10]
Original list:
[0, 1, 3, 5, 0, 3, 4, 5, 0, 8, 0, 3, 6, 0, 3, 1, 1, 0]
True
True
False
154. Write a Python program to join two given list of lists of the same length, element wise.
Original lists:
[[10, 20, 61], [30, 40, 12, 14, 15], [50, 60, 12, 13, 19, 20], [30, 20, 80, 12]]
Original lists:
[['a', 'b', 'p', 'q'], ['b', 'c', 'd', 'p', 's', 't'], ['e', 'f', 'u', 'v', 'w']]
155. Write a Python program to add two given lists of different lengths, starting on the left.
Original lists:
[2, 4, 7, 0, 5, 8]
[3, 3, -1, 7]
Add said two lists from left:
[5, 7, 6, 7, 5, 8]
Original lists:
[1, 2, 3, 4, 5, 6]
[2, 4, -3]
[3, 6, 0, 4, 5, 6]
156. Write a Python program to add two given lists of different lengths, starting on the right.
Original lists:
[2, 4, 7, 0, 5, 8]
[3, 3, -1, 7]
Original lists:
[1, 2, 3, 4, 5, 6]
[2, 4, -3]
[1, 2, 3, 6, 9, 3]
Original lists:
[2, 4, 7, 0, 5, 8]
[2, 5, 8]
[0, 1]
[3, 3, -1, 7]
Interleave said lists of different lengths:
[2, 2, 0, 3, 4, 5, 1, 3, 7, 8, -1, 0, 7, 5, 8]
158. Write a Python program to find the maximum and minimum values in a given list of tuples.
[('V', 60), ('VI', 70), ('VII', 75), ('VIII', 72), ('IX', 78), ('X', 70)]
(78, 60)
159. Write a Python program to append the same value/a list multiple times to a list/list-of-lists.
[1, 2, 3, 4, 5, 5, 5, 5, 5, 5]
[[5, 6, 7], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5]]
160. Write a Python program to remove the first specified number of elements from a given list satisfying
a condition.
Remove the first 4 number of even numbers from the following list:
[3,10,4,7,5,7,8,3,3,4,5,9,3,4,9,8,5]
Output:
[3, 7, 5, 7, 3, 3, 5, 9, 3, 4, 9, 8, 5]
Original list:
[3, 10, 4, 7, 5, 7, 8, 3, 3, 4, 5, 9, 3, 4, 9, 8, 5]
[3, 7, 5, 7, 3, 3, 5, 9, 3, 4, 9, 8, 5]
161. Write a Python program to check if a given list increases strictly. Moreover, if removing only one
element from the list results in a strictly increasing list, we still consider the list true.
True
True
True
True
True
True
True
True
True
True
True
False
False
False
False
False
162. Write a Python program to find the last occurrence of a specified item in a given list.
Original list:
['s', 'd', 'f', 's', 'd', 'f', 's', 'f', 'k', 'o', 'p', 'i', 'w', 'e', 'k', 'c']
15
14
12
163. Write a Python program to get the index of the first element that is greater than a specified element.
Original list:
[12, 45, 23, 67, 78, 90, 100, 76, 38, 62, 73, 29, 83]
Index of the first element which is greater than 73 in the said list:
Index of the first element which is greater than 21 in the said list:
Index of the first element which is greater than 80 in the said list:
Index of the first element which is greater than 55 in the said list:
164. Write a Python program to get items from a given list with specific conditions.
Original list:
[12, 45, 23, 67, 78, 90, 45, 32, 100, 76, 38, 62, 73, 29, 83]
Number of Items of the said list which are even and greater than 45
5
165. Write a Python program to split a given list into specified-sized chunks.
Original list:
[12, 45, 23, 67, 78, 90, 45, 32, 100, 76, 38, 62, 73, 29, 83]
[[12, 45, 23], [67, 78, 90], [45, 32, 100], [76, 38, 62], [73, 29, 83]]
[[12, 45, 23, 67], [78, 90, 45, 32], [100, 76, 38, 62], [73, 29, 83]]
[[12, 45, 23, 67, 78], [90, 45, 32, 100, 76], [38, 62, 73, 29, 83]]
166. Write a Python program to remove the None value from a given list.
Original list:
167. Write a Python program to convert a given list of strings into a list of lists.
[['R', 'e', 'd'], ['M', 'a', 'r', 'o', 'o', 'n'], ['Y', 'e', 'l', 'l', 'o', 'w'], ['O', 'l', 'i', 'v', 'e']]
168. Write a Python program to display vertically each element of a given list, list of lists.
Original list:
Original list:
147
253
586
169. Write a Python program to convert a given list of strings and characters to a single list of characters.
Original list:
Convert the said list of strings and characters to a single list of characters:
['r', 'e', 'd', 'w', 'h', 'i', 't', 'e', 'a', 'b', 'b', 'l', 'a', 'c', 'k', 'f']
170. Write a Python program to insert an element in a given list after every nth position.
Original list:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
Insert a in the said list after 2 nd element:
Original lists:
172. Write a Python program to remove the last N number of elements from a given list.
Original lists:
173. Write a Python program to merge some list items in a given list using the index value.
Original lists:
['a', 'b', 'c', 'd', 'e', 'f', 'g']
174. Write a Python program to add a number to each element in a given list of numbers.
Original lists:
[3, 8, 9, 4, 5, 0, 5, 0, 3]
Original lists:
175. Write a Python program to find the minimum and maximum value for each tuple position in a given
list of tuples.
Original list:
Maximum value for each tuple position in the said list of tuples:
[7, 6]
Minimum value for each tuple position in the said list of tuples:
[0, 1]
176. Write a Python program to create a new list by dividing two given lists of numbers.
Original list:
[7, 2, 3, 4, 9, 2, 3]
[7, 2, 3, 4, 9, 2, 3]
177. Write a Python program to find common elements in a given list of lists.
Original list:
[2, 3]
Original list:
['c']
178. Write a Python program to insert a specified element in a given list after every nth element.
Original list:
Original list:
['s', 'd', 'f', 'j', 's', 'a', 'j', 'd', 'f', 'd']
['s', 'd', 'f', 'Z', 'j', 's', 'a', 'Z', 'j', 'd', 'f', 'Z', 'd']
179. Write a Python program to create the largest possible number using the elements of a given list of
positive integers.
Original list:
Largest possible number using the elements of the said list of positive integers:
9744341403
Original list:
Largest possible number using the elements of the said list of positive integers:
605040302010
Original list:
[8, 4, 2, 9, 5, 6, 1, 0]
Largest possible number using the elements of the said list of positive integers:
98654210
180. Write a Python program to create the smallest possible number using the elements of a given list of
positive integers.
Original list:
Smallest possible number using the elements of the said list of positive integers:
3404143749
Original list:
Smallest possible number using the elements of the said list of positive integers:
102030405060
Original list:
[8, 4, 2, 9, 5, 6, 1, 0]
Smallest possible number using the elements of the said list of positive integers:
01245689
181. Write a Python program to iterate a given list cyclically at a specific index position.
Original list:
182. Write a Python program to calculate the maximum and minimum sum of a sublist in a given list of
lists.
Original list:
[[1, 2, 3, 5], [2, 3, 5, 4], [0, 5, 4, 1], [3, 7, 2, 1], [1, 2, 1, 2]]
[2, 3, 5, 4]
[1, 2, 1, 2]
183. Write a Python program to get the unique values in a given list of lists.
Original list:
[[1, 2, 3, 5], [2, 3, 5, 4], [0, 5, 4, 1], [3, 7, 2, 1], [1, 2, 1, 2]]
Original list:
[['h', 'g', 'l', 'k'], ['a', 'b', 'd', 'e', 'c'], ['j', 'i', 'y'], ['n', 'b', 'v', 'c'], ['x', 'z']]
['e', 'd', 'c', 'b', 'x', 'k', 'n', 'h', 'g', 'j', 'i', 'a', 'l', 'y', 'v', 'z']
184. Write a Python program to generate Bigrams of words from a given list of strings.
From Wikipedia:
A bigram or digram is a sequence of two adjacent elements from a string of tokens, which are typically
letters, syllables, or words. A bigram is an n-gram for n=2. The frequency distribution of every bigram in a
string is commonly used for simple statistical analysis of text in many applications, including in
computational linguistics, cryptography, speech recognition, and so on.
Original list:
['Sum all the items in a list', 'Find the second smallest number in a list']
[('Sum', 'all'), ('all', 'the'), ('the', 'items'), ('items', 'in'), ('in', 'a'), ('a', 'list'), ('Find', 'the'), ('the', 'second'),
('second', 'smallest'), ('smallest', 'number'), ('number', 'in'), ('in', 'a'), ('a', 'list')]
185. Write a Python program to convert a given decimal number to a binary list.
Original Number: 8
[1, 0, 0, 0]
Original Number: 45
[1, 0, 1, 1, 0, 1]
Original list:
187. Write a Python program to convert a given list of tuples to a list of strings.
188. Write a Python program to sort a given list of tuples by a specified element.
[('item2', 10, 10.12), ('item3', 15, 25.1), ('item1', 11, 24.5), ('item4', 12, 22.5)]
[('item1', 11, 24.5), ('item2', 10, 10.12), ('item3', 15, 25.1), ('item4', 12, 22.5)]
Sort on 2nd element of the tuple of the said list:
[('item2', 10, 10.12), ('item1', 11, 24.5), ('item4', 12, 22.5), ('item3', 15, 25.1)]
[('item2', 10, 10.12), ('item4', 12, 22.5), ('item1', 11, 24.5), ('item3', 15, 25.1)]
189. Write a Python program to shift last element to first position and first element to last position in a
given list.
Original list:
[1, 2, 3, 4, 5, 6, 7]
Shift last element to first position and first element to last position of the said list:
[7, 2, 3, 4, 5, 6, 1]
Original list:
Shift last element to first position and first element to last position of the said list:
190. Write a Python program to find the specified number of largest products from two given lists,
multiplying an element from each list.
Original lists:
[1, 2, 3, 4, 5, 6]
[3, 6, 8, 9, 10, 6]
Original lists:
[2, 3, 5, 8, 7, 2, 3]
[4, 3, 9, 0, 4, 3, 9]
[2, 1, 5, 6, 5, 5, 4]
192. Write a Python program to remove all strings from a given list of tuples.
Original list:
[(100, 'Math'), (80, 'Math'), (90, 'Math'), (88, 'Science', 89), (90, 'Science', 92)]
Original list:
(2, 2)
Original list:
(2, 3)
Original list:
(3, 3)
194. Write a Python program to sum two or more lists. The lengths of the lists may be different.
Original list:
[4, 8, 8]
Original list:
[8, 6, 4]
195. Write a Python program to traverse a given list in reverse order, and print the elements with the
original index.
Original list:
black
white
green
red
3 black
2 white
1 green
0 red
Original list:
Original list:
Original list:
197. Write a Python program to compute the average of the n-th element in a given list of lists with
different lengths.
Original list:
[[0, 1, 2], [2, 3, 4], [3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14]]
Average of n-th elements in the said list of lists with different lengths:
Original lists:
[1, 2, 3, 4, 5, 6]
Compare said two lists and get the indices of the values present in both lists:
[1, 4]
Original lists:
[1, 2, 3, 4, 5, 6]
Compare said two lists and get the indices of the values present in both lists:
[4]
Original lists:
[1, 2, 3, 4, 15, 6]
Compare said two lists and get the indices of the values present in both lists:
[]
Original lists:
Original lists:
[1, 2, 3, 4, 5, 6]
[[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]
Original lists:
[1, 2, 3, 4, 5]
201. Write a Python program to check if a given string contains an element that is present in a list.
https://www.w3resource.com/python-exercises/list/
True
https://www.w3resource.net
Check if https://www.w3resource.net contains an element, which is present in the list ['.com', '.edu', '.tv']
False
202. Write a Python program to find the indexes of all None items in a given list.
Original list:
[1, 4, 6, 7]
203. Write a Python program to join adjacent members of a given list.
Original list:
Original list:
['12']
204. Write a Python program to check if the first digit or character of each element in a list is the same.
Original list:
Check if first digit in each element of the said given list is same or not!
True
Original list:
Check if first digit in each element of the said given list is same or not!
False
Original list:
Check if first character in each element of the said given list is same or not!
True
Original list:
False
205. Write a Python program to find the indices of elements in a given list that are greater than a
specified value.
Original list:
[3, 6]
Original list:
[]
206. Write a Python program to remove additional spaces from a given list.
Original list:
['abc ', ' ', ' ', 'sdfds ', ' ', ' ', 'sdfds ', 'huy']
207. Write a Python program to find the common tuples between two given lists.
Original lists:
Original lists:
208. Sum a list of numbers. Write a Python program to sum the first number with the second and divide it
by 2, then sum the second with the third and divide by 2, and so on.
Original list:
[1, 2, 3, 4, 5, 6, 7]
Original list:
209. Write a Python program to count the number of groups of non-zero numbers separated by zeros in a
given list of numbers.
Original list:
[3, 4, 6, 2, 0, 0, 0, 0, 0, 0, 6, 7, 6, 9, 10, 0, 0, 0, 0, 0, 5, 9, 9, 7, 4, 4, 0, 0, 0, 0, 0, 0, 5, 3, 2, 9, 7, 1]
210. Write a Python program to compute the sum of non-zero groups (separated by zeros) of a given list
of numbers.
Original list:
[3, 4, 6, 2, 0, 0, 0, 0, 0, 0, 6, 7, 6, 9, 10, 0, 0, 0, 0, 0, 7, 4, 4, 0, 0, 0, 0, 0, 0, 5, 3, 2, 9, 7, 1, 0, 0, 0]
Compute the sum of non-zero groups (separated by zeros) of the said list of numbers: [15, 38, 15, 27]
Original list:
After deleting an element:, using index of the element: [98, 'Math', 90, 'Science']
212. Write a Python program to remove all values except integer values from a given array of mixed
values.
After removing all the values except integer values from the said array of mixed values: [12, 0]
213. Write a Python program to calculate the sum of two lowest negative numbers in a given array of
integers.
An integer (from the Latin integer meaning "whole") is colloquially defined as a number that can be
written without a fractional component. For example, 21, 4, 0, and -2048 are integers.
Original list elements: [-14, 15, -10, -11, -12, -13, 16, 17, 18, 19, 20]
Sum of two lowest negative numbers of the said array of integers: -27
214. Write a Python program to sort a given positive number in descending/ascending order.
215. Write a Python program to merge two or more lists into a list of lists, combining elements from each
of the input lists based on their positions.
Sample Output:
216. Write a Python program to group the elements of a list based on the given function and return the
count of elements in each group.
Sample Output:
{6: 2, 4: 1}
{3: 2, 5: 1}
217. Write a Python program to split values into two groups, based on the result of the given filtering
function.
Sample Output:
Sample Output:
219. Write a Python program to build a list, using an iterator function and an initial seed value.
Sample Output:
220. Write a Python program to map the values of a list to a dictionary using a function, where the key-
value pairs consist of the original value as the key and the result of the function as the value.
Sample Output:
{1: 1, 2: 4, 3: 9}
221. Write a Python program to randomize the order of the values of a list, returning a new list.
Sample Output:
[3, 2, 4, 1, 6, 5]
222. Write a Python program to get the difference between two given lists, after applying the provided
function to each list element of both.
Sample Output:
[1.2]
[{'x': 2}]
223. Write a Python program to create a list with non-unique values filtered out.
Sample Output:
[1, 3, 5]
224. Write a Python program to create a list with unique values filtered out.
Sample Output:
[2, 4]
225. Write a Python program to retrieve the value of the nested key indicated by the given selector list
from a dictionary or list.
Sample Output:
Harwood
226. Write a Python program to get a list of elements that exist in both lists, after applying the provided
function to each list element of both.
Sample Output:
[2.1]
227. Write a Python program to get the symmetric difference between two lists, after applying the
provided function to each list element of both.
Sample Output:
[1.2, 3.4]
228. Write a Python program to get every element that exists in any of the two given lists once, after
applying the provided function to each element of both.
Sample Output:
[2.2, 4.1]
229. Write a Python program to find the index of the first element in the given list that satisfies the
provided testing function.
Sample Output:
230. Write a Python program to find the indexes of all elements in the given list that satisfy the provided
testing function.
Sample Output:
[0, 2]
231. Write a Python program to split values into two groups, based on the result of the given filter list.
Sample Output:
Sample Output:
233. Write a Python program to chunk a given list into n smaller lists.
Sample Output:
234. Write a Python program to convert a given number (integer) to a list of digits.
Sample Output:
[1, 2, 3]
[1, 3, 4, 7, 8, 2, 3]
235. Write a Python program to find the index of the last element in the given list that satisfies the
provided testing function.
Sample Output:
236. Write a Python program to find items that are parity outliers in a given list.
Sample Output:
[1, 3]
[2, 4, 6]
237. Write a Python program to convert a given list of dictionaries into a list of values corresponding to
the specified key.
Sample Output:
238. Write a Python program to calculate the average of a given list, after mapping each element to a
value using the provided function.
Sample Output:
5.0
15.0
239. Write a Python program to find the value of the first element in the given list that satisfies the
provided testing function.
Sample Output:
240. Write a Python program to find the value of the last element in the given list that satisfies the
provided testing function.
Sample Output:
241. Write a Python program to create a dictionary with the unique values of a given list as keys and their
frequencies as values.
Sample Output:
{3: 4, 4: 2, 7: 1, 5: 2, 9: 1, 0: 1, 2: 1}
242. Write a Python program to get the symmetric difference between two iterables, without filtering out
duplicate values.
Sample Output:
[30, 40]
243. Write a Python program to check if a given function returns True for every element in a list.
Sample Output:
True
False
False
244. Write a Python program to initialize a list containing the numbers in the specified range where start
and end are inclusive and the ratio between two terms is step. Return an error if step equals 1.
Sample Output:
245. Write a Python program that takes any number of iterable objects or objects with a length property
and returns the longest one.
Sample Output:
Green
[1, 2, 3, 4, 5]
[1, 2, 3, 4]
246. Write a Python program to check if a given function returns True for at least one element in the list.
Sample Output:
True
False
247. Write a Python program to calculate the difference between two iterables, without filtering duplicate
values.
Sample Output:
[3]
248. Write a Python program to get the maximum value of a list, after mapping each element to a value
using a given function.
Sample Output:
249. Write a Python program to get the minimum value of a list, after mapping each element to a value
using a given function.
Sample Output:
2
250. Write a Python program to calculate the sum of a list, after mapping each element to a value using
the provided function.
Sample Output:
20
251. Write a Python program that fills a list with the specified value.
Sample Output:
[0, 0, 0, 0, 0, 0, 0]
[3, 3, 3, 3, 3, 3, 3, 3]
252. Write a Python program to get the n maximum elements from a given list of numbers.
Sample Output:
[1, 2, 3]
[1, 2, 3]
Sample Output:
[1, 2, 3]
[1, 2, 3]
254. Write a Python program to get the weighted average of two or more numbers.
Sample Output:
[2, 5, 3]
39.0
82.97272727272727
Sample Output:
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
Sample Output:
[1, 2]
[1, 2, 3, 4]
[(), (1,), (2,), (3,), (4,), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4), (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4), (1, 2, 3, 4)]
257. Write a Python program to check if two given lists contain the same elements regardless of order.
Sample Output:
[1, 2, 4]
[2, 4, 1]
Check two said lists contain the same elements regardless of order!
True
[1, 2, 3]
[1, 2, 3]
Check two said lists contain the same elements regardless of order!
True
[1, 2, 3]
[1, 2, 4]
Check two said lists contain the same elements regardless of order!
False
258. Write a Python program to create a flat list of all the keys in a flat dictionary.
Sample Output:
259. Write a Python program to check if a given function returns True for at least one element in the list.
Sample Output:
False
True
False
260. Write a Python program to check if all the elements of a list are included in another given list.
Sample Output:
True
False
261. Write a Python program to get the most frequent element in a given list of numbers.
Sample Output:
Original list:
[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 2, 4, 6, 9, 1, 2]
Original list:
[1, 2, 3, 1, 2, 3, 2, 1, 4, 3, 3]
3
262. Write a Python program to move the specified number of elements to the end of the given list.
Sample Output:
[4, 5, 6, 7, 8, 1, 2, 3]
[6, 7, 8, 1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7, 8]
[8, 1, 2, 3, 4, 5, 6, 7]
[2, 3, 4, 5, 6, 7, 8, 1]
263. Write a Python program to move the specified number of elements to the start of the given list.
Sample Output:
[4, 5, 6, 7, 8, 1, 2, 3]
[6, 7, 8, 1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, 6, 7, 8]
[8, 1, 2, 3, 4, 5, 6, 7]
[2, 3, 4, 5, 6, 7, 8, 1]
264. Write a Python program to create a two-dimensional list from a given list of lists.
Sample Output:
265. Write a Python program to generate a list containing the Fibonacci sequence, up until the nth term.
Sample Output:
[0, 1, 1, 2, 3, 5, 8, 13]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711,
28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887,
9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437,
701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025]
266. Write a Python program to cast the provided value as a list if it's not one.
Sample Output:
<class 'list'>
[1]
<class 'tuple'>
['Red', 'Green']
<class 'set'>
['Green', 'Red']
<class 'dict'>
[1, 2, 3]
267. Write a Python program to get the cumulative sum of the elements of a given list.
Sample Output:
[1, 2, 3, 4]
[1, 3, 6, 10]
268. Write a Python program to get a list with n elements removed from the left and right.
Sample Output:
[1, 2, 3]
[2, 3]
[1, 2]
[3, 4]
[1, 2]
[1, 2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]
[1, 2, 3, 4, 5]
269. Write a Python program to get every nth element in a given list.
Sample Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[2, 4, 6, 8, 10]
[5, 10]
[6]
270. Write a Python program to check if the elements of the first list are contained in the second one
regardless of order.
Sample Output:
True
True
False
True
271. Write a Python program to check if there are duplicate values in a given flat list.
Sample Output:
Original list:
[1, 2, 3, 4, 5, 6, 7]
Check if there are duplicate values in the said given flat list:
False
Original list:
[1, 2, 3, 3, 4, 5, 5, 6, 7]
Check if there are duplicate values in the said given flat list:
True
272. Write a Python program to generate a list of numbers in the arithmetic progression starting with
the given positive integer and up to the specified limit.
Sample Output:
[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]
273. Write a Python program to find an element that divides a given list of integers with the same sum
value.
Sample Output:
Original list:
[0, 9, 2, 4, 5, 6]
Element that devides the said list of integers with the same sum value:
Original list:
[-4, 0, 6, 1, 0, 2]
Element that devides the said list of integers with the same sum value:
Original list:
[1, 2, 3, 4]
Element that devides the said list of integers with the same sum value:
No such element!
Original list:
[-4, 0, 5, 1, 0, 1]
Element that devides the said list of integers with the same sum value:
274. Write a Python program to count the lowercase letters in a given list of words.
Sample Data:
275. Write a Python program to add all elements of a list of integers except the number at index. Return
the updated string.
Sample Data:
276. Write a Python program to find the largest odd number in a given list of integers.
Sample Data:
277. Write a Python program to calculate the largest and smallest gap between sorted elements of a list
of integers.
Sample Data:
Sample Data:
Sample Data:
("Python", 2) -> "n is less than number of vowels present in the string."
280. Write a Python program that takes a list of integers and finds all pairs of integers that differ by three.
Return all pairs of integers in a list.
Sample Data:
[0, -3, -5, -7, -8] -> [[-3, 0], [-8, -5]]