Question: Answer each of the following questions: 1. Write the code segment that does the following: opens a file named MyName.txt, writes your first name to

Answer each of the following questions:

1. Write the code segment that does the following: opens a file named MyName.txt, writes your first name to the file, and then closes the file.

2. Write the code segment that does the following: opens a file named MyName.txt, reads the first line from the file and displays it, and then closes the file.

3. Assume that the MyName.txt file is currently closed. Write the code segment that opens the file without erasing it, write another name to the file so that it is appended to the end of the files existing data, and close the file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!