Question Bank For Module 4
Question Bank For Module 4
2. Explain any three commonly used string methods in Python with examples.
Lists
Tuples
11. What are tuples, and how do they differ from lists?
12. Explain the concept of tuple packing and unpacking with examples.
14. What are the benefits of using tuples over lists in Python?
Dictionaries
16. What are dictionary keys and values? Explain with an example.
17. Explain the get() method in dictionaries. How does it differ from direct key access?
19. Differentiate between lists, tuples, and dictionaries with respect to mutability and use cases.
20. What are nested lists, and how are they accessed?
21. Write a one-line Python code using list comprehension to create a list of squares for numbers 1
to 10.
Programming Questions (5 Marks Each)
Strings
1. Write a program to count the number of vowels, consonants, and spaces in a given string.
Lists
4. Write a Python function to flatten a nested list (e.g., [[1, 2], [3, 4]] → [1, 2, 3, 4]).
5. Create a program that takes a list of numbers as input and returns a new list with only the even
numbers using list comprehension.
Tuples
6. Write a program that accepts a list of tuples containing student names and marks, and returns
the name of the student with the highest marks.
7. Write a function that takes a tuple of numbers as an argument and returns the sum of all
elements.
Dictionaries
8. Write a Python program to count the frequency of each character in a string using a dictionary.
9. Write a program to merge two dictionaries and sort the resulting dictionary by its keys.
10. Create a program that takes a dictionary as input and prints only the keys with unique values.
o Write a program to create a list of 5 numbers and print each element on a new line.
o Write a program to access the first, last, and middle elements of a list.
o Write a program to calculate and print the sum of all elements in a list.
o Write a Python program to find the largest and smallest numbers in a list.
5. Counting Occurrences
o Write a program to count how many times a specific value appears in a list.
6. Reversing a List
o Write a program to find and print all the even numbers from a list of integers.
o Write a program to create a new list containing the squares of each number from an
input list.
o Write a program to take a list as input and print the index of a specific element.
o Write a program to create a copy of a list without using the copy() method.
o Write a program to sort a list of numbers in ascending order without using the sort()
method.
o Write a program to find and print the common elements between two lists.
10. Create a dictionary using the fromkeys() method with default values.
15. Create a dictionary from two lists: one for keys and one for values.
20. Write a program to combine values of common keys from two dictionaries.