CBSE Class 12 Computer Science Question 64 of 136

Data File Handling — Question 3

Back to all questions
3
Question

Question 3

How are open() functions different from close() functions other than their functionality of opening and closing files?

Answer
open() functionsclose() functions
It creates a file object, which allows to perform various operations on the file, such as reading from it, writing to it, or appending data to it.When we're done working with a file, we should always close it using the close() function to free up system resources and prevent data loss.
The syntax is : file_objectname = open("filename", "mode")The syntax is : file.close()