Question bank python.docx
Question bank python.docx
Question Bank
Sr.
Question Text Marks CO
No.
1 : Overview of Python, Programming languages
1 What is Python? 2 CO-1
2 Describe the history and evolution of Python. 3
36 How do you add, remove, and update elements in a Python list? CO-2
Provide examples for each operation.
Demonstrate creating, accessing, and modifying elements in a CO-2
37 4
list.
38 Define a function in Python and explain its scope and argument 4 CO-2
types
How append() and extend() are different with reference to list in
39 4 CO-2
Python?
Explain how the pop(),remove(),reverse()and insert() methods CO-2
40 5
list work in Python. Provide examples for each.
Discuss the scope and lifetime of variables in Python functions CO-2
41 5
with examples.
Explain the difference between return and void functions in CO-2
42 4/5
Python. Provide examples.
Explain the use of following built in function in python. max(), pow(), CO-2
43 4/5
str(), input()
Explain any three basic operations that can be performed on a tuple 3 CO-3
51
with examples.
54 Given a tuple (10, 20, 30, 40), write a Python code to unpack the 4 CO-3
elements into four variables.
Define key-value pairs in a dictionary and demonstrate access
55 3 CO-3
and modification.
56 Differentiate between lists and dictionaries. 3 CO-3
57 Explain sets in Python and their unique properties. 4 CO-3
58 Differentiate between sets and dictionaries. 3 CO-3
59 Differentiate List and Tuple in Python. 3 CO-3
Consider the list lst=[9,8,7,6,5,4,3]. Write the Python program CO-3
which performs the following operation without using built-in
methods.
1) Insert element 10 at beginning of the list.
60 5
2) Insert element 2 at end of the list.
3) Delete the element at index position 5.
What is dictionary in Python? Explain with an example.
61 Describe any four common set methods with examples. 4 CO-3
Create a set fruit_set with the values {"apple", "banana", CO-3
"cherry"}.Add the value "date" to fruit_set. Print the updated
62 5
fruit_set. Remove the value "banana" from fruit_set. Print the
modified fruit_set.
Create a tuple fruit_tuple with the values ("apple", "banana", CO-3
"cherry"). Access and print the second element of fruit_tuple
using indexing. Extract and print the substring containing
"banana" and "cherry" using slicing.
63 5
Create another tuple more_fruits with the values ("date",
"elderberry"). Concatenate fruit_tuple and more_fruits into a
new tuple all_fruits and print it. Use the len() function to print
the number of elements in all_fruits.
Create a dictionary named person_info with the following keys: CO-3
"name", "age", "occupation", and "hobbies".Populate the
dictionary with values of your choice. "hobbies" should be a list
64 of at least three hobbies. Print the person_info dictionary. Access 5
and print the value associated with the "occupation" key. Update
the "age" value to a new age and print the updated dictionary.
Add a new key-value pair "email" with a value of your choice to
the dictionary and print the updated dictionary.
Create a dictionary named product_prices with at least four CO-3
key-value pairs where the keys are product names (strings) and
the values are their prices (floats). Print the product_prices
65 dictionary. Increase the price of each product by 5% using a for 5
loop and update the dictionary accordingly. Print the updated
dictionary with the new prices. Use the .get() method to safely
access the price of a specific product of your choice and print it.
Discuss the relationship between tuples and dictionaries with CO-3
66 5
examples.
Describe dictionary example in python. How to access CO-3
67 3
individual members?
4 : File Handling
68 Explain the concept of file handling in Python. 3 CO-4
Demonstrate opening, reading, writing, and closing files in
69 4 CO-4
Python.
70 What is the purpose of the with statement in file handling? 3 CO-4
71 Explain Python modules and how to import them into your code. 4 CO-4
Explain modulo operator in python with the help of suitable
72 4 CO-4
example.
73 Explain different mode for opening a file in python 5 CO-4
74 What is the Pickle module used for in Python? 5 CO-4
75 How do you read and write binary files in Python? 4/5 CO-4
76 What are the primary differences between text files and binary files? 4 CO-4
77 How do you create a new text file and write data to it in Python? 3 CO-4
78 What methods can be used to read the contents of a text file? 4 CO-4
79 Which Python methods are commonly used for writing data to a file? 3 CO-4
80 Which Python methods are commonly used for writing data to a file? 4 CO-4
81 How do you read a CSV file into a list of dictionaries using Python? 5 CO-4