0% found this document useful (0 votes)
37 views4 pages

Question Bank For Module 4

Uploaded by

haswanth.0432
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)
37 views4 pages

Question Bank For Module 4

Uploaded by

haswanth.0432
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/ 4

Short Answer Questions (2–3 Marks Each)

Strings and String Methods

1. Define a string in Python. How is it different from a list?

2. Explain any three commonly used string methods in Python with examples.

3. How can you reverse a string in Python? Provide a code snippet.

4. Write a Python expression to check if a substring exists within a string.

5. What is string slicing? Provide an example.

Lists

6. Explain the concept of mutability in Python lists with an example.

7. What is list aliasing? Why can it be problematic?

8. Differentiate between shallow copy and deep copy of a list.

9. What is a list comprehension? Provide a syntax example.

10. How are lists used as function parameters?

Tuples

11. What are tuples, and how do they differ from lists?

12. Explain the concept of tuple packing and unpacking with examples.

13. Can you modify a tuple in Python? Justify your answer.

14. What are the benefits of using tuples over lists in Python?

Dictionaries

15. Define a dictionary in Python. How is it different from a list or tuple?

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?

18. Write an expression to merge two dictionaries in Python.

Comparison and Advanced List Processing

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.

2. Create a function that checks if two strings are anagrams.

Lists

3. Write a program to remove all duplicate elements from a list.

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.

Simple List Programs (3–5 Marks Each)


1. Basic Operations on Lists

o Write a program to create a list of 5 numbers and print each element on a new line.

2. Accessing List Elements

o Write a program to access the first, last, and middle elements of a list.

3. Sum of List Elements

o Write a program to calculate and print the sum of all elements in a list.

4. Largest and Smallest 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 reverse a list without using the reverse() method.

7. Even Numbers in a List

o Write a program to find and print all the even numbers from a list of integers.

8. Square of List Elements

o Write a program to create a new list containing the squares of each number from an
input list.

9. Concatenating Two Lists

o Write a program to concatenate two lists into one.

10. Removing a Specific Element

o Write a program to remove a specific element from a list by its value.

11. List Indexing

o Write a program to take a list as input and print the index of a specific element.

12. Cloning a List

o Write a program to create a copy of a list without using the copy() method.

13. Sorting a List

o Write a program to sort a list of numbers in ascending order without using the sort()
method.

14. Finding Common Elements

o Write a program to find and print the common elements between two lists.

15. Inserting Elements into a List

o Write a program to insert a new element at the second position in a list.


Simple Dictionary Questions

1. Create a dictionary with 3 key-value pairs and print it.

2. Access and print the value of a specific key in a dictionary.

3. Add a new key-value pair to an existing dictionary.

4. Update the value of an existing key in a dictionary.

5. Delete a specific key-value pair from a dictionary.

6. Check if a key exists in a dictionary.

7. Write a program to iterate through the keys and values of a dictionary.

8. Count the number of keys in a dictionary.

9. Merge two dictionaries into one.

10. Create a dictionary using the fromkeys() method with default values.

11. Reverse the keys and values in a dictionary.

12. Count the frequency of each character in a string using a dictionary.

13. Find the key with the maximum value in a dictionary.

14. Remove all entries from a dictionary.

15. Create a dictionary from two lists: one for keys and one for values.

16. Write a program to print only the keys of a dictionary.

17. Write a program to print only the values of a dictionary.

18. Sort a dictionary by its keys and print the result.

19. Sort a dictionary by its values and print the result.

20. Write a program to combine values of common keys from two dictionaries.

You might also like