Create a program in Python to calculate grade point averages for college students. Grade point averages are calculated by dividing total number of quality points by the total number of earned credit hours. Quality points are grades earned multiplied by the credit hours of a course. A grade of A is worth 4 points, B is 3 points, C is 2 points, D is 1 point and an F is 0 points.
Your program should prompt the student to enter their name, total credit hours earned, and total quality points earned. Calculate the grade point average and display back the student’s name along with their gpa for my example of John Doe.
Hi John Doe. Your grade point average is 3.30.
name= input("Enter your name: ")
x=float(input("Enter the credit hours you earned: ")) #credit hours earned
y=float(input("Enter the quality points earned: ")) #quality points
z=(y)/(x)
if z>=4 and z<=4.9:
grade='A'
elif z>=3 and z<=3.9:
grade='B'
elif z>=2 and z<=2.9:
grade='C'
elif z>=1 and z<=1.9:
grade='D'
elif z>=0 and z<=0.9:
grade='F'
else:
grade="Invalid grade"
print("Hi",name,".","Your grade point average is", z)
Comments
Leave a comment