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
Get step-by-step solutions from verified subject matter experts
