I am trying to write a program in PYTHON that will open a file named StudyHours.txt. The program will read in data from a text file named StudyHours.txt. The user of the program will be prompted to correct any bad data. The program updates the corrected information in StudyHours.txt file. For example if the file contains a letter grade of K which is not a possible letter grade(possible grades are A,B,C,D,F).  The StudyHours.txt file contains this info: Aaron Rodgers 12 A Tom Brady 9 K Philip Rivers 3 c Joe Theismann 15 B As you can see there is a K  listed for a grade for Tom Brady. How do I change that K to a valid grade by prompting an input from the user and then recording that change in the StudyHours.txt file so that the file reads: Aaron Rodgers 12 A Tom Brady 9 A (changed from K to what the user inputs)- say the user inputs an A Philip Rivers 3 c Joe Theismann 15 B This is what I have to start with. Assume the file is opened and the \n is stripped. while gradeDesired > 'F' or gradeDesired == 'E':           print('Invalid grade! Enter a grade of A,B,C,D, or F')          gradeDesired = input('Enter a correct grade of A,B,C,D, or F ) So when the user enters an A, I need the program to change that K to an A within that StudyHours.txt file. Thanks, Gary

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

I am trying to write a program in PYTHON that will open a file named StudyHours.txt. The program will read in data from a text file named StudyHours.txt. The user of the program will be prompted to correct any bad data. The program updates the corrected information in StudyHours.txt file. For example if the file contains a letter grade of K which is not a possible letter grade(possible grades are A,B,C,D,F).  The StudyHours.txt file contains this info:

Aaron Rodgers

12

A

Tom Brady

9

K

Philip Rivers

3

c

Joe Theismann

15

B

As you can see there is a K  listed for a grade for Tom Brady. How do I change that K to a valid grade by prompting an input from the user and then recording that change in the StudyHours.txt file so that the file reads:

Aaron Rodgers

12

A

Tom Brady

9

A (changed from K to what the user inputs)- say the user inputs an A

Philip Rivers

3

c

Joe Theismann

15

B

This is what I have to start with. Assume the file is opened and the \n is stripped.

while gradeDesired > 'F' or gradeDesired == 'E': 
         print('Invalid grade! Enter a grade of A,B,C,D, or F')
         gradeDesired = input('Enter a correct grade of A,B,C,D, or F )

So when the user enters an A, I need the program to change that K to an A within that StudyHours.txt file.

Thanks,

Gary

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning