_________method reads all the lines and returns the lines along with newline character, as a list of strings.
_________method reads all the lines and returns the lines along with newline character, as a list of strings.
Solution
✅ Correct Option: 3
The readlines() method reads all the lines of a file and returns them as a list of strings. Each string is one line and keeps its trailing newline character ().
Option 1: read() returns the whole file content as one single string, not a list.
Option 2: readline() reads only one line at a time, not all lines.
Option 4: read_line() is not a valid Python file method.
Related questions:
2025: 22 May Shift 1
2025: 15 May Shift 2
2026: 19 May Shift 1
2026: 26 May Shift 1
2026: 20 May Shift 1