Examine the given Python program and select the best purpose of the program…
2023
Examine the given Python program and select the best purpose of the program from the given options: File = open("Poem.txt", "r") print(len(File.readline().split())) File.close()
- A.
to count the number of words present in the file
- B.
to count the number of lines present in the file
- C.
to count the number of characters present in the file
- D.
to count the number of words present in the first line of the file
Attempted by 1449 students.
Show answer & explanation
Correct answer: D
This program reads the first line of the file Poem.txt , splits it into words , and prints the total number of words in that first line.