E8.1Write a program that carries out the following tasks: Open a file with the name hello.txt. Store the message "Hello, World!" in the file. Close the file. Open the same file again. Read the message into a string variable and print it.

Respuesta :

Answer:

Explanation:

#Although no programming language is stated,

#Python will be used for the program

#to start, open the intended file

#Then write to the file

file = open("hello.txt", "w")

file.write("Hello, World!")

file.close()

file=open("hello.txt", "r")

data=file.read()

#this line prints the text in the file

print(data)

file.close()

In this exercise we have to use the knowledge of computational language in python to describe the code, like this:

We can find the code in the attached image.

How to use files in Python?

To open a file, Python has the open() function. It takes two parameters: the first is the name of the file to be opened, and the second parameter is the way we want to work with that file - whether we want to read or write.

The code can be written more simply as:

file = open("hello.txt", "w")

file.write("Hello, World!")

file.close()

file=open("hello.txt", "r")

data=file.read()

print(data)

file.close()

See more about python at brainly.com/question/26104476

Ver imagen lhmarianateixeira