Question:

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:

Updated On: Mar 29, 2025
  • (A), (B), (C), (D)
  • (B), (A), (C), (D)
  • (B), (D), (C), (A)
  • (B), (D), (A), (C)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

The correct order of the statements to write data to a file is (B), (A), (C), (D).

Additional Context:

  • File Handling Sequence:
    1. (B) Open file: Create/overwrite "CUET.TXT" in write mode
    2. (A) Write data: Insert the string "CUET EXAMINATION"
    3. (C) Print confirmation: User feedback message
    4. (D) Close file: Release system resources

Correct Answer: (2) (B), (A), (C), (D).

Was this answer helpful?
0
0