πŸ“Š Python
Q. Which of the following will correctly read all lines from a file `file.txt`?
  • (A) with open('file.txt') as f: data = f.readlines()
  • (B) with open('file.txt') as f: data = f.read()
  • (C) open('file.txt').readlines()
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above

Explanation: All these methods can read lines; readlines() returns a list of lines, read() returns entire content.

Explanation by: Mr. Dubey
All these methods can read lines; readlines() returns a list of lines, read() returns entire content.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
44
Total Visits
πŸ“½οΈ
8 mo ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
81%
Success Rate