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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education