Skip to main contentSkip to solution

Match the LIST-I with LIST-II

LIST-ILIST-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 IList 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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question