Solveeit Logo

Question

Computer Science Question on File Handling in Python

Consider the following code and specify the correct order of the statements to be written:
Code:
(A) f.write(”CUET EXAMINATION”)
(B) f=open(”CUET.TXT”, ”w”)
(C) print(”Data is Written Successfully”)
(D) f.close()
Choose the correct answer from the options given below:

A

(A), (B), (C), (D)

B

(B), (A), (C), (D)

C

(B), (D), (C), (A)

D

(B), (D), (A), (C)

Answer

(B), (A), (C), (D)

Explanation

Solution

In Python, the correct sequence for file handling includes opening the file, writing to it, printing a success message, and then closing the file.