QUESTION BANK
Course Code: 24BTPHY204/24BTELY205 Semester: II
Course: Programming in Python
Module 3: Lists—Tuples—Sets
Lists
1. What is a list in Python? How is it different from an array?
2. Write a program to demonstrate indexing and slicing of a list.
3. Explain list concatenation and repetition with suitable examples.
4. Write a program to update elements in a list using indexing and slicing.
5. How does the in and not in operators work in a list? Illustrate with examples.
6. Compare two lists using comparison operators and explain the output.
7. Write a Python program to demonstrate membership and comparison operations on
lists.
8. List and explain any five commonly used list methods with examples.
9. Write a program using append(), insert(), remove(), sort(), and reverse() on a list.
10. Write a function that accepts a list and returns the sum of all its elements.
11. What are multidimensional lists? Create a 2D list and access its elements.
12. Define List? Explain append (), insert () and remove () methods with examples.
13. How is a tuple different from a list and what function is used to convert list to tuple?
Explain.
14. Explain different ways to delete an element from a list with suitable Python
syntax and programming examples
15. Explain append() and index() functions with respect to lists in Python.
16. Write the output of the following python code >>>spam=’Hello worls!’
i) >>> spam[0] ii) >>>spam[4] iii) >>>spam[-1] iv) >>>spam[0:5]
v) >>> spam[:5] vi) >>>spam[7:]
17 explain following methods used in list with an example.
i. len() ii. sum() iii) max() iv) min
18. What is the difference between a multidimensional list and a nested list with
examples?
19 Explain the difference between a List and a Generator in Python.
20. What is the difference between remove() and pop() methods in lists?
Tuples
1. What is a tuple in Python? How is it different from a list?
2. Explain tuple indexing and slicing with examples.
3. Write a program to demonstrate multiple assignment using tuples.
4. Explain the different Tuple operations supported by python with suitable example.
5. Explain different tuple methods used in python with an example.
6. Write a program to find maximum and minimum element of tuple.
7. . Compare lists and tuples in terms of mutability, performance, and use cases.
Set
1. What is a set in Python? How do you create a set?
2. Write a program to create a set from a list and remove duplicates.
3. Demonstrate the use of add(), update(), remove(), discard(), and clear() methods on sets.
4. What is the difference between remove() and discard() in sets?
5. Write a program to perform union, intersection, and Symmetric Difference of two sets.
6. Explain the different set operations supported by python with suitable example.
7. Difference between a discard() method and a remove() method