πŸ“Š Python
Q. What will this code do?
file = open('data.txt', 'r')
data = file.read()
file.close()
Code:
file = open('data.txt', 'r')
data = file.read()
file.close()
  • (A) Writes data to file
  • (B) Reads full content of file into data variable
  • (C) Deletes file content
  • (D) Appends data to file
πŸ’¬ Discuss
βœ… Correct Answer: (B) Reads full content of file into data variable

Explanation: read() reads the whole file content into the data variable.

Explanation by: Mr. Dubey
read() reads the whole file content into the data variable.

πŸ’¬ Discussion


πŸ“Š Question Analytics

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