Match the LIST-I with LIST-II
LIST-I LIST-II A. write() I. Used to read a specified number of bytes (n) of data from a data file B. readlines() II. Reads all lines and returns a line along new line character as list of strings C. read() III. Takes a string as an argument and writes to the text file D. writelines() IV. Used to write multiple strings to a file
Match the LIST-I with LIST-II
| LIST-I | LIST-II | ||
|---|---|---|---|
| A. | write() | I. | Used to read a specified number of bytes (n) of data from a data file |
| B. | readlines() | II. | Reads all lines and returns a line along new line character as list of strings |
| C. | read() | III. | Takes a string as an argument and writes to the text file |
| D. | writelines() | IV. | Used to write multiple strings to a file |
Solution
✅ Correct Option: 2
| List I | List II |
|---|---|
| (A) write() | (III) Takes a string as an argument and writes to the text file |
| (B) readlines() | (II) Reads all lines and returns a line along new line character as list of strings |
| (C) read() | (I) Used to read a specified number of bytes (n) of data from a data file |
| (D) writelines() | (IV) Used to write multiple strings to a file |
write() takes a single string, while writelines() takes a list (or other iterable) of strings.
readlines() returns a list in which each line keeps its trailing newline character.
Related questions:
2025: 27 May Shift 2
2026: 11 May Shift 2
2025: 15 May Shift 2
2025: 22 May Shift 1