You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
x, y=input(f"Course {i+1} grade: "), int(input(f"Credits for course {i+1}: "))
11
+
self.course_grades.append((x.upper(), y))
12
+
print()
13
+
forxinself.course_grades:
14
+
ifx[0].upper() notinGRADE_TO_GP:
15
+
self.if_invalid_grade=f"{x[0].upper()} is not a valid grade!"
16
+
self.is_valid_grade=False
17
+
returnself.is_valid_grade
18
+
returnself.is_valid_grade
19
+
20
+
defoverall_gpa_using_previous(self):
21
+
ifself.grade_validator():
22
+
current_gpa=float(input("Current overall GPA: "))
23
+
print()
24
+
credits_completed_till_now=int(input("Total credits completed till now: "))
25
+
print()
26
+
current_sem_product=0
27
+
total_credits=0
28
+
forgrade, creditsinself.course_grades:
29
+
current_sem_product+=credits*GRADE_TO_GP[grade]
30
+
total_credits+=credits
31
+
returnf"Expected Overall GPA after the current semester: {round((current_sem_product+ (current_gpa*credits_completed_till_now))/(total_credits+credits_completed_till_now), 2)}"
choice=input("\n*** GPA Calculator ***\n\n1. Calcualte expected GPA after the current semester\n2. Calculate the GPA using each course's grade\n3. Press 'q' to quit\n\nYour choice number: ")
58
+
print()
59
+
try:
60
+
ifchoice=="1":
61
+
number_of_courses=int(input("Number of courses taken in the current semester: "))
62
+
new_gpa=GPACalculator(number_of_courses)
63
+
print(new_gpa.overall_gpa_using_previous())
64
+
elifchoice=="2":
65
+
number_of_courses=int(input("Number of courses taken: "))
0 commit comments