CBSE Class 12 Computer Science Question 94 of 145

File Handling — Question 11

Back to all questions
11
Question

Question 11

Write a statement in Python to perform the following operations :

(a) To open a text file "BOOK.TXT" in read mode

(b) To open a text file "BOOK.TXT" in write mode

Answer

(a) To open a text file "BOOK.TXT" in read mode : file1 = open("BOOK.TXT", "r")

(b) To open a text file "BOOK.TXT" in write mode : file2 = open("BOOK.TXT", "w")