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

Assign5 (T&T)

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

Assign5 (T&T)

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

Assignment 6 [List and Tuple]

NAME: KUNAL KUMAR SINGH


ROLL: 2105555
SECTION: CSE 31

1. Write a program to find the sum of all elements of a list

2. Write a program to find the maximum and minimum element of a list.


3. Write a program to find the position of maximum and minimum element’s position in a
list.

4. Write a program to print all the element in a list that are greater than a given value.
5. Write a program to print all the common elements of 2 list.

6. Write a program to reverse a list.


7. Write a program to find the second largest and second smallest value from a list.

8. Write a program to find the average of all elements in a list.


9. Write a program to to generate random numbers within a given range and store it in a list.

10. Write a program to split the even and odd elements into 2 different lists.
11. Write a Python program to create a tuple

12. Write a Python program to create a tuple with different data types.
13. Write a Python program to unpack a tuple in several variables.

14. Write a Python program to add an item in a tuple.


15. Write a Python program to convert a tuple to a string.

16. Write a Python program to get the 4th element and 4th element from last of a tuple.
17. Write a Python program to find the repeated items of a tuple.

18. Write a Python program to check whether an element exists within a tuple.
19. Write a Python program to slice a tuple.

20. Write a Python program to find the index of an item of a tuple.


21. Write a Python program to find the length of a tuple.

22. Write a Python program to convert a tuple to a dictionary.


23. Write a Python program to unzip a list of tuples into individual lists.

24. Write a Python program to reverse a tuple.


25. Write a Python program to convert a list of tuples into a dictionary.

26. Write a Python program to print a tuple with string formatting.

Sample tuple : (100, 200, 300)

Output : This is a tuple (100, 200, 300)


27. Write a Python program to replace last value of tuples in a list.

Sample list: [(10, 20, 40), (40, 50, 60), (70, 80, 90)]

Expected Output: [(10, 20, 100), (40, 50, 100), (70, 80, 100)]

28. Write a Python program to replace last value of tuples in a list.

Sample data: [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]

Expected output: [('',), ('a', 'b'), ('a', 'b', 'c'), 'd']


29. Write a Python program to sort a tuple by its float element.

Sample data: [('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')]

Expected Output: [('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')]

30. Write a Python program to count the elements in a list until an element is a tuple.

You might also like