Annotate following code. def QualityPointCalculator(qualPnts, crdts):    if crdts > 0:        return qualPnts/crdts    return 0 def convertGrade(grade):    if grade == "A":        return 4.00    elif grade == "A-":        return 3.70    elif grade == "B+":        return 3.30    elif grade == "B":        return 3.00    elif grade == "B-":        return 2.70    elif grade == "C+":        return 2.30    elif grade == "C":        return 2.00    elif grade == "C-":        return 1.70    elif grade == "D+":        return 1.30    elif grade == "D":        return 1.00    else:        return 0.00        def calcQualPnts(pnts, crdts):    return pnts*crdts    if __name__ == '__main__':    quality_points = []     course_names = []     grades = []     credits = []            final_gpa = 0.0    semester_gpa = 0.0    final_total = 0.0       howMany = 0    print('GRADE & QUALITY NUMERICAL POINTS')    choice = input('Would you like to calculate your GPA for a term? Enter Y/N: ')    while choice.upper()[0] == 'Y':                       howMany = int(input('How many courses did you take in the term: '))                for i in range(howMany):                        course_name = input('Enter the name of course '+str(i+1)+': ')                        course_names.append(course_name)                       credit = float(input('Enter the number of credits associated with that course: '))                        credits.append(credit)                      grade = input('Enter the grade for the course: ')                        grade = grade.upper()            grades.append(grade)                        quality_point = calcQualPnts(convertGrade(grade),credit)            quality_points.append(quality_point)                       semester_gpa += quality_point                                  print('\nThis term you have earned:')        print('%-15s%-10s%-10s%-15s' %('Course','Credits','Grade','Quality Points'))        for i in range(howMany):            print('%-15s%-10d%-10s%-15.1f' %(course_names[i],credits[i],grades[i],quality_points[i]))                   print('Total earned credits this term: %d' %(sum(credits)))                gpa = QualityPointCalculator(sum(quality_points),sum(credits))        print('You earned %.1f quality points and a GPA of %.2f for the term.' %(sum(quality_points),gpa))                final_gpa += semester_gpa                final_total += sum(credits)                choice = input("\nWould you like to calculate another term's GPA? Enter Y/N: ")               quality_points = []        course_names = []        grades = []        credits = []        semester_gpa = 0         print('\nYour overall earned credits: %d '%final_total)    gpa = QualityPointCalculator(final_gpa,final_total)    print('Your overall GPA: %.2f' %(gpa))

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

Annotate following code.

def QualityPointCalculator(qualPnts, crdts):
   if crdts > 0:
       return qualPnts/crdts
   return 0
def convertGrade(grade):
   if grade == "A":
       return 4.00
   elif grade == "A-":
       return 3.70
   elif grade == "B+":
       return 3.30
   elif grade == "B":
       return 3.00
   elif grade == "B-":
       return 2.70
   elif grade == "C+":
       return 2.30
   elif grade == "C":
       return 2.00
   elif grade == "C-":
       return 1.70
   elif grade == "D+":
       return 1.30
   elif grade == "D":
       return 1.00
   else:
       return 0.00
      

def calcQualPnts(pnts, crdts):
   return pnts*crdts
  
if __name__ == '__main__':
   quality_points = [] 
   course_names = [] 
   grades = [] 
   credits = [] 
  
   

   final_gpa = 0.0
   semester_gpa = 0.0
   final_total = 0.0
  
   howMany = 0
   print('GRADE & QUALITY NUMERICAL POINTS')
   choice = input('Would you like to calculate your GPA for a term? Enter Y/N: ')
   while choice.upper()[0] == 'Y':
      
       
       howMany = int(input('How many courses did you take in the term: '))
       
       for i in range(howMany):
           
           course_name = input('Enter the name of course '+str(i+1)+': ')
           
           course_names.append(course_name)
          
           credit = float(input('Enter the number of credits associated with that course: '))
           
           credits.append(credit)
         
           grade = input('Enter the grade for the course: ')
           
           grade = grade.upper()
           grades.append(grade)
           
           quality_point = calcQualPnts(convertGrade(grade),credit)
           quality_points.append(quality_point)
          
           semester_gpa += quality_point
          
       
      
       print('\nThis term you have earned:')
       print('%-15s%-10s%-10s%-15s' %('Course','Credits','Grade','Quality Points'))
       for i in range(howMany):
           print('%-15s%-10d%-10s%-15.1f' %(course_names[i],credits[i],grades[i],quality_points[i]))
          
       print('Total earned credits this term: %d' %(sum(credits)))
       
       gpa = QualityPointCalculator(sum(quality_points),sum(credits))
       print('You earned %.1f quality points and a GPA of %.2f for the term.' %(sum(quality_points),gpa))
       
       final_gpa += semester_gpa
       
       final_total += sum(credits)
       
       choice = input("\nWould you like to calculate another term's GPA? Enter Y/N: ")
      
       quality_points = []
       course_names = []
       grades = []
       credits = []
       semester_gpa = 0
    
   print('\nYour overall earned credits: %d '%final_total)
   gpa = QualityPointCalculator(final_gpa,final_total)
   print('Your overall GPA: %.2f' %(gpa))  

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

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