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:
- A.
String (str)
- B.
List
- C.
Tuple
- 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 ('').