Answer to Question #262016 in Python for mari

Question #262016

Build a GPA calculator that inputs grades of 3 different subjects along with the credit hours

from the user and displays the user’s GPA. The input grades and their corresponding grading

points are given below.Grade Points

A 4.0

A- 3.67

B+ 3.33

B 3.0

B- 2.67

C+ 2.33

C 2.0

C- 1.67

D+ 1.33

D 1.0

F 0


1
Expert's answer
2021-11-06T11:48:04-0400
gradesPoints={"A":4.0, "A-": 3.67, "B+": 3.33, "B": 3.0, "B-": 2.67,"C+": 2.33,"C": 2.0, "C-":1.67, "D+":1.33, "D": 1.0, "F":0}
grades=[]




sumGradeCreditHoursProduct=0.0
sumCreditHours=0.0
for i in range(1,4):
    grade=input(f"Enter the grade for subject {i}: ")
    hours=float(input(f"Enter the credit hours for subject {i}: "))
    sumGradeCreditHoursProduct+=gradesPoints[grade]*hours
    sumCreditHours+=hours


GPA=sumGradeCreditHoursProduct/sumCreditHours


print("Your GPA: {:.2f}".format(GPA))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS