def determineHours():        with open ("StudyHours.txt", "r") as file1:               data = file1.readlines()               total_study_hours = 0        for i, line in enumerate(data):               if "error" in line:                      print(f"Error found in line {i + 1}: {line}")                      correct = input("Do you want to correct this line?(y\n)")                      if correct == "y":                             new_line = input("Enter corrected line:")                             data[i]=new_line        for record in data:               fields = record.strip().split(',')               name = fields[0].title()               credits = int(fields[1])               grade = fields[2]               if grade == 'A':#determine weekly study hours based on desired grade                      study_hours = 15 * credits               elif grade == 'B':                      study_hours = 12 * credits                elif grade == 'C':                      study_hours = 9 * credits               elif grade == 'D':                      study_hours = 6 * credits               elif grade == 'F':                      study_hours == 0               else:                      print("Invalid grade for student {'name'}")               with open ("HowManyHours.txt", 'a') as write_file:                      write_file.write(f"{name},{credits},{study_hours},{grade}\n")                    ******Here is my code, I will attach the errors I am recieving if you wouldnt mind helping me figure these out, I would appreciate it. I believe it is saying that the index field I am trying to assign isnt valid. I will also attach the file it is pulling from so you can view.  The program will READ in data from a text file named StudyHours.txt. The user corrects any bad data. The program updates the information in StudyHours.txt file. For example if the file contains a letter grade of K which is not a possible letter grade. You will create and submit a text file with a minimum of 5 additional records from example below. The file is named StudyHours.txt and contains the following format:  first line full name second line number of credits third line grade desired for each class

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

def determineHours():
       with open ("StudyHours.txt", "r") as file1:
              data = file1.readlines()
              total_study_hours = 0

       for i, line in enumerate(data):
              if "error" in line:
                     print(f"Error found in line {i + 1}: {line}")
                     correct = input("Do you want to correct this line?(y\n)")
                     if correct == "y":
                            new_line = input("Enter corrected line:")
                            data[i]=new_line
       for record in data:
              fields = record.strip().split(',')
              name = fields[0].title()
              credits = int(fields[1])
              grade = fields[2]

              if grade == 'A':#determine weekly study hours based on desired grade
                     study_hours = 15 * credits
              elif grade == 'B':
                     study_hours = 12 * credits 
              elif grade == 'C':
                     study_hours = 9 * credits
              elif grade == 'D':
                     study_hours = 6 * credits
              elif grade == 'F':
                     study_hours == 0
              else:
                     print("Invalid grade for student {'name'}")

              with open ("HowManyHours.txt", 'a') as write_file:
                     write_file.write(f"{name},{credits},{study_hours},{grade}\n")

                   ******Here is my code, I will attach the errors I am recieving if you wouldnt mind helping me figure these out, I would appreciate it. I believe it is saying that the index field I am trying to assign isnt valid. I will also attach the file it is pulling from so you can view. 

The program will READ in data from a text file named StudyHours.txt. The user corrects any bad data. The program updates the information in StudyHours.txt file. For example if the file contains a letter grade of K which is not a possible letter grade. You will create and submit a text file with a minimum of 5 additional records from example below. The file is named StudyHours.txt and contains the following format: 
first line full name
second line number of credits
third line grade desired for each class

StudyHours - Notepad
File Edit Format View Help
philip Rivers
apple
с
Joe Theismann
15
B
Aaron RODgers
12
A
Tom brady
9
K
JULIO JONES
50
P
tyREEK hill
12
C
MIKE gisecki
21
A
DREW brees
12
B
AJ Mccarron
15
C
Mac JONES
9
A
A
Type here to search
O
jo
(99+
Ln 1, Col 1
100%
Rain...
Windows (CRLF)
0
I
0
UTF-8
9:30 AM
1/25/2023
X
125
Transcribed Image Text:StudyHours - Notepad File Edit Format View Help philip Rivers apple с Joe Theismann 15 B Aaron RODgers 12 A Tom brady 9 K JULIO JONES 50 P tyREEK hill 12 C MIKE gisecki 21 A DREW brees 12 B AJ Mccarron 15 C Mac JONES 9 A A Type here to search O jo (99+ Ln 1, Col 1 100% Rain... Windows (CRLF) 0 I 0 UTF-8 9:30 AM 1/25/2023 X 125
IDLE Shell 3.10.6
File Edit Shell Debug Options Window Help
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license ()" for more information.
A
A: Determine Hours to Study:
B: Determine Grade:
C: Display Averages and Totals:
D: Quit Program.
=========== RESTART: C:\Users\User\OneDrive\Desktop\F\Final Project.py ==========
Welcome user to the Grade Calculator Version 2.0. I thank you for continuing support for this program. This allows us to continue focusing on making apps you will
love. Thanks. Programmer: Shonda Deese
Main Menu
Enter your menu choice: A
Traceback (most recent call last):
File "C:\Users\User\OneDrive\Desktop\F\Final Project.py", line 191, in <module>
Project.py",
line 88, in determineHours
choice_option [ch] ()
File "C:\Users\User\OneDrive\Desktop\F\Final
credits = int (fields [1])
IndexError: list index out of range
Type here to search
O
jo
(99+
I
Rain... AD
0
X
Ln: 19 Col: 0
9:26 AM
1/25/2023 125
Transcribed Image Text:IDLE Shell 3.10.6 File Edit Shell Debug Options Window Help Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license ()" for more information. A A: Determine Hours to Study: B: Determine Grade: C: Display Averages and Totals: D: Quit Program. =========== RESTART: C:\Users\User\OneDrive\Desktop\F\Final Project.py ========== Welcome user to the Grade Calculator Version 2.0. I thank you for continuing support for this program. This allows us to continue focusing on making apps you will love. Thanks. Programmer: Shonda Deese Main Menu Enter your menu choice: A Traceback (most recent call last): File "C:\Users\User\OneDrive\Desktop\F\Final Project.py", line 191, in <module> Project.py", line 88, in determineHours choice_option [ch] () File "C:\Users\User\OneDrive\Desktop\F\Final credits = int (fields [1]) IndexError: list index out of range Type here to search O jo (99+ I Rain... AD 0 X Ln: 19 Col: 0 9:26 AM 1/25/2023 125
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Linux
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