1. What is a function in Python?
2. Which keyword is used to define a function?
3. What does a function return if no return statement is given?
4. Differentiate between built-in and user-defined functions.
5. Write a function to check whether a number is even or odd.
6. Explain the difference between function definition and function call with an example.
7. Write a program to create a function that takes two numbers and returns their sum,
difference, product, and quotient.
8. Explain the importance of docstrings in functions with examples.
9. What are positional parameters?
10. Define default parameters with an example.
11. What are *args and **kwargs used for?
12. Differentiate between positional and keyword parameters.
13. Write a function that takes name and age as parameters and prints them using
keyword arguments.
14. Write a function using *args to calculate the sum of any number of integers.
15. Write a program using **kwargs to display student details like name, roll number,
course, and city.
16. What is a lambda function?
17. Give the syntax of a lambda function.
18. Can a lambda function have multiple expressions?
19. Write a lambda function to find the square of a number.
20. Explain why functions are called “first-class objects” in Python.
21. Write a program using lambda and map() to calculate the cube of each element in a
list.
22. Compare lambda functions and normal functions with suitable examples.
23. What is the use of map() function?
24. Which module provides the reduce() function?
25. Write a one-line code using filter() to get even numbers from a list.
26. Explain the difference between map() and filter() with examples.
27. Write a program using reduce() to find the product of numbers in a list.
28. Write a Python program using map() and lambda to multiply two lists element-wise.
29. Demonstrate the use of map, filter, and reduce in a single program with proper
explanation.
30. How do you create a string in Python?
31. What does the len() function return for a string?
32. What is string immutability?
33. Explain string slicing with examples.
34. Differentiate between positive and negative indexing in strings.
35. Write a function to count the number of vowels in a string.
36. Write a program to check if a string is a palindrome.
37. Explain string methods like upper(), lower(), find(), and split() with examples.
38. Define a list in Python.
39. Are lists mutable or immutable?
40. What is the output of [1,2,3]*2?
41. Write a program to append and extend elements to a list.
42. Explain list slicing with an example.
43. Differentiate between append() and extend().
44. Write a program to demonstrate traversing a list using both for loop and range().
45. Write a program using map, filter, and reduce functions on a list of numbers.
46. Differentiate between “equivalent” and “identical” objects.
47. Which operator is used to check object identity?
48. Are strings mutable or immutable?
49. Explain the concept of string interning in Python.
50. Write a program to show that two variables can refer to the same object.
51. With examples, explain the difference between == and is operator.
52. Write a program to check whether two lists are identical or not.
53. What is aliasing?
54. Why is aliasing dangerous with mutable objects?
55. Write a program to show aliasing in lists.
56. Explain with an example how changes in one alias affect the other.
57. Discuss aliasing with respect to mutable and immutable objects. Give suitable Python
examples.
58. What happens when a list is passed to a function?
59. Does append() return a new list or modify the original?
60. Write a function delete_head() that deletes the first element of a list.
61. Explain with an example the difference between operations that modify lists and
operations that create new lists.
62. Write a program to demonstrate the difference between append() and + operator
when used with lists.
63. Explain how list references work when passed as function arguments, using diagrams
if possible.
64. What is a tuple in Python?
65. State two differences between tuples and lists.
66. Can tuples contain duplicate values?
67. What is the output of t = (5,) ; type(t)?
68. Explain tuple immutability with an example.
69. Write Python code to create a tuple from the string "python".
70. Differentiate between (‘a’) and (‘a’,) in Python.
71. Write a Python program to swap two variables using tuple assignment.
72. Explain relational operations on tuples with examples.
73. Write a function min_max(t) that returns both minimum and maximum values of a
tuple.
74. What is tuple assignment?
75. Which built-in function returns quotient and remainder as a tuple?
76. Write a Python statement to split an email "
[email protected]" into username and
domain using tuple assignment.
77. Explain with an example how a function can return multiple values using tuples.
78. Write a function that takes a list of numbers and returns a tuple containing (sum,
average, maximum, minimum).
79. Compare conventional variable swapping with tuple assignment.
80. What is *args in Python functions?
81. What is meant by “scatter” operation in Python?
82. Write a program using *args that prints all arguments passed to it.
83. Show how to use scatter (unpacking) with divmod() function.
84. Explain gathering and scattering of arguments in detail with code examples.
85. Write a program that accepts any number of numbers using *args and returns their
average.
86. What does the zip() function do in Python?
87. What happens if sequences of unequal length are zipped?
88. Write a program to combine two lists ['a','b','c'] and [1,2,3] using zip.
89. Explain tuple assignment in a for loop using zip with an example.
90. Write a Python program using zip to check if two sequences have any matching
element at the same index.
91. Demonstrate with a program how zip objects can be converted into lists and
dictionaries.
92. Can lists be used as dictionary keys? Why/Why not?
93. What does d.items() return in a dictionary?
94. Write a program to create a dictionary from a list of tuples [('a',1),('b',2)].
95. Explain how zip can be used to create a dictionary.
96. Write a program to store telephone numbers using tuples as dictionary keys
((lastname, firstname)).
97. Explain with examples:
a) Dictionary from list of tuples
b) Updating dictionary with list of tuples
98. What are dictionary keys and values?
99. Which method is used to check if a key exists in a dictionary?
100. Write the syntax to create an empty dictionary.
101. Explain dictionary properties with an example.
102. Write a program to count occurrences of each letter in a word using a
dictionary.
103. Differentiate between in operator for keys and values in a dictionary.
104. Write a program to implement reverse lookup (finding keys from a value).
105. Explain get() method of dictionary with examples.
106. Write and explain a Python program to print histogram of characters in sorted
order.
107. Which function is used to open a file in Python?
108. What happens if you open a file in write ("w") mode?
109. Write the syntax to open a file in append mode.
110. Write a program to open a file and print its contents.
111. Differentiate between write mode and append mode.
112. Why should we close a file after operations?
113. Write Python programs for:
a) Writing into a file.
b) Appending into a file.
c) Deleting a file.
114. Explain different file modes ("r", "w", "a") with examples.
115. Write a program that reads a text file and counts how many lines, words, and
characters it contains.