A

Admin • 833.24K Points
Coach

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
  • Correct Answer - Option(B)
  • Views: 24
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.