Class 12 Computer Science: Python Revision and File Handling Worksheet

Answer the questions and tap Submit to see your score. Your progress is auto-saved on this device.

Jump to question
Q1 · MCQ · 1 mark
Which of the following modes is used to open a file for both reading and writing, creating it if it doesn't exist, and overwriting its contents if it does?
Q2 · MCQ · 1 mark
What will be the output of the following Python code snippet? ```python def func(a, b=5): print(a - b) func(10) func(b=2, a=8) ```
Q3 · FILL · 1 mark
The `____` method in file handling is used to read at most 'n' bytes from the file.
Q4 · MCQ · 1 mark
Which of the following is an immutable data type in Python?
Q5 · MCQ · 1 mark
What is the purpose of the `with open(...) as f:` statement in Python?
Q6 · SHORT · 2 marks
Differentiate between a global variable and a local variable in Python.
Q7 · FILL · 1 mark
To handle exceptions in Python, the `try` block is followed by an `____` block.
Q8 · MCQ · 1 mark
Which error will occur if you try to open a non-existent file in 'r' mode?
Q9 · FILL · 1 mark
The `____` mode is used to open a file for writing, appending content to the end of the file.
Q10 · SHORT · 2 marks
Explain the concept of 'seek()' method in file handling with an example.
0 of 10 answered0%