Consider the following Python program segment: File =open('Poem.txt, 'r')…

2023

Consider the following Python program segment: File =open('Poem.txt, 'r') T=File.readline( ) Identify the data type of T:

  1. A.

    String (str)

  2. B.

    List

  3. C.

    Tuple

  4. D.

    Dictionary

Attempted by 1803 students.

Show answer & explanation

Correct answer: A

Answer: String (str) Explanation: readline() reads one line from the file and returns it as a string. It includes the trailing newline character (\n) if the line ends with one. When the file pointer is at the end of the file, readline() returns an empty string ('').

Explore the full course: Rssb Senior Computer Instructor