Writing Errands

Write a Python program to compute the average GPA of the courses taken by a student. The program gets the grade and credit count of each course from the user. The grades can be A, B, C, D, or F and the credit counts can be 2, 3, or 5. The program checks the validity of the grades and credit counts before using them. The program continues ignoring invalid inputs until a valid value is entered by the user. Moreover, the user enters DONE after entering the grade and credit count of all courses. To calculate the average GPA, the program first computes the grade points for each course, which is the multiplication of the equivalent numerical grade (A: 4.0, B: 3.0, C: 2.0, D: 1.0, and F: 0.0) and the credit count of the course. Next, the program calculates the total grade points, the sum of the grade points of all courses, and divides it to the total credit count. For example, if a student got grade A for the first course, which has credit count of 3 and C for the second course with credit count of 5, then the average GPA of the student is (4.0 * 3 + 2.0 * 5) / (3 + 5) = 2.75. Finally, the program prints the average GPA with two digits of precision in the screen.

× Chat on WhatsApp