81.5k views
1 vote
Write a program that opens the my_name.txt file that was created by the program in problem 1, reads your name from the file, displays the name on the screen, then closes the file.

1 Answer

5 votes

Answer:

#using python

def main ():

infile=open(‘my_name.txt’, ‘r’)

#using read method to read file contents

File_contents=infile.read()

#close

infile.close()

#display

print(file_contents)

#finally call main method()

main()

User Tom Osterbind
by
5.6k points