0% found this document useful (0 votes)
86 views

Length Is 2 or More and The First and Last Character Are Same From A Given List of Strings

The document contains 35 problems involving lists in Python. The problems cover a wide range of tasks like summing/multiplying list elements, finding max/min values, sorting lists, checking for common elements, concatenating lists, and performing arithmetic on lists.

Uploaded by

Anuj Ruhela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Length Is 2 or More and The First and Last Character Are Same From A Given List of Strings

The document contains 35 problems involving lists in Python. The problems cover a wide range of tasks like summing/multiplying list elements, finding max/min values, sorting lists, checking for common elements, concatenating lists, and performing arithmetic on lists.

Uploaded by

Anuj Ruhela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

 Write a Python program to sum all the items in a list. 

2. Write a Python program to multiplies all the items in a list. 

3. Write a Python program to get the largest number from a list. 

4. Write a Python program to get the smallest number from a list. 

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)]

7. Write a Python program to check a list is empty or not. 

8. Write a Python program to clone or copy a list. 

9. Write a Python program to find the list of words that are longer than n from
a given list of words. 

10. 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']

13. 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). 

14. Write a Python program to get the difference between the two lists. 

15. Write a Python program to find the second smallest number in a list. 

16. Write a Python program to find the second largest number in a list. 

17. Write a Python program to add unique values into a list L2 from a list L1

18. Write a Python program to get the frequency of the elements in a list. 

19. Write a Python program to check whether a list contains a sublist. 

20. 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']

21. 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]
Common index elements of the said lists:
[1, 7]

22. Write a Python program to compute average of two given lists. 


Original list:
[1, 1, 3, 4, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 4, 5, 7, 8]
Average of two lists:
3.823529411764706

23. Write a Python program to find the item with maximum 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]
Item with maximum occurrences of the said list:
2

24. Write a Python program to check whether a specified list is sorted or not. 


Original list:
[1, 2, 4, 6, 8, 10, 12, 14, 16, 17]
True

Original list:
[1, 2, 4, 6, 8, 10, 12, 14, 16, 17]
False

25. Write a Python program to check if the elements of a given list are unique
or not. 
Original list:
[1, 2, 4, 6, 8, 2, 1, 4, 10, 12, 14, 12, 16, 17]
False

Original list:
[2, 4, 6, 8, 10, 12, 14]
True

26. Write a Python program to reverse strings in a given list of string values. 


Original lists:
['Red', 'Green', 'Blue', 'White', 'Black']
Reverse strings of the said given list:
['deR', 'neerG', 'eulB', 'etihW', 'kcalB']

27. Write a Python program to calculate the product of the unique numbers of


a given list. 
Original List : [10, 20, 30, 40, 20, 50, 60, 40]
Product of the unique numbers of the said list: 720000000

28. Write a Python program to interleave multiple lists of the same length. 


Original list:
list1: [1, 2, 3, 4, 5, 6, 7]
list2: [10, 20, 30, 40, 50, 60, 70]
list3: [100, 200, 300, 400, 500, 600, 700]
Interleave multiple lists:
[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70,
700]

29. Write a Python program to calculate the sum of the numbers in a list


between the indices of a specified range. 
Original list:
[2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12]
Range: 8 , 10 (Both inclusive)

10+11+8=29
30. Write a Python program to sort a given mixed list of integers and strings.
Numbers must be sorted before strings. 
Original list:
[19, 'red', 12, 'green', 'blue', 10, 'white', 'green', 1]
Sort the said mixed list of integers and strings:
[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']

31. Write a Python program to compute the sum of digits of each number of a


given list. 
Original tuple:
[10, 2, 56]
Sum of digits of each number of the said list of integers:
14
Original tuple:
[10, 20, 4, 5, 'b', 70, 'a']
Sum of digits of each number of the said list of integers:
19
Original tuple:
[10, 20, -4, 5, -70]
Sum of digits of each number of the said list of integers:
19

32. Write a Python program to add two given lists of different lengths, start
from 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]

33. WAP to input two matrices from the user and find the addition of the
matrices.

34. WAP to input two matrices from the user and find the multiplication of the
matrices.
35. WAP to input a matrix from the user and find the Transpose of the matrix.

You might also like