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:
Answer: A. String (str) — 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…
- A.
String (str)
- B.
List
- C.
Tuple
- D.
Dictionary
Attempted by 1895 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 ('').
Loading lesson…