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