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()

  1. A.

    to count the number of words present in the file

  2. B.

    to count the number of lines present in the file

  3. C.

    to count the number of characters present in the file

  4. 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.

Explore the full course: Rssb Senior Computer Instructor