CBSE Class 12 Computer Science Question 5 of 136

Data File Handling — Question 5

Back to all questions
5
Question

Question 5

Assertion (A): The close() method is used to close the file.

Reasoning (R): While closing a file, the system frees up all the resources like CPU processor time and memory allocated to it.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.
Answer

Both A and R are true and R is the correct explanation of A.

Explanation
The close() method in Python is used to flush any unwritten information, and close the file object, preventing further writing. While closing a file, the system frees up resources such as CPU processor time and memory that were allocated to the file.