Question: Use python Files and exceptions 1- Modify the program you wrote for Chapter 6 Exercise 6 so it handles the following exceptions: It should handle

Use python "Files and exceptions"

1- Modify the program you wrote for Chapter 6 Exercise 6 so it handles the following exceptions: It should handle IOError exceptions that are raised when the file is opened and data is read from it by printing "Trouble opening file. Try again." and not executing any more of the code. It should handle any ValueError exceptions that are raised when the items that are read from the file are converted to a number by printing "File must have only numbers. Try again." and not executing any more of the code.

2- The Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write a program that will read each player's name and score as keyboard input, and then save these as records in a file named golf.txt. First, have the program ask the user how many players they want to add to their record. Then, ask the user for each name and score individually. golf.txt should be structured so that there is a line with the player's name, folowed by their score on the next line. Emily 30 Mike 20 Jonathan 23

3- Write a program that reads the records from the golf.txt file written in Exercise 10a and prints them in the following format: Name: Emily Score: 30 Name: Mike Score: 20 Name: Jonathan Score: 23

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!