Question: Python 3 Write a recursive function gpa calculator() that takes a single argument: . grades: a list containing altermating letter grades and credits for a
Python 3
Write a recursive function gpa calculator() that takes a single argument:

. grades: a list containing altermating letter grades and credits for a group of courses taken by a student (see below for further explanation). Only the grades A, B, C, D and F are possible. A list of grades like ['A, 3, 'B',4, 'D',3) indicates that the student took three courses with the respective credit values (3, 4 and 3). The function computes the weighted GPA and returns it. Note that letter grades can be provided in uppercase or lowercase. Note: Your code should be able to handle invalid grades by returning None. Invalid grades include: negative or zero credit value. 2. A letter grade that is not one of A/a/B/b/C/c/D/d/FIf. Hint: Consider using helper functions to calculate (1) the total number of credits and (2) the GPA. Pseudocode is given for both below Pseudocode for a helper function that calculates the credit total: def credit sum helper (grades): if the length of grades is zero then return 0.0 otherwise let x - the letter grade of the first course in the 1ist let y - the of credits of the first course in the list if either x or y is invalid then return None let z- sum of credits of the courses after current course if 2 is None then return None otherwise return the sum y 2 Pseudocode for a helper function that calculates the total grade points: def grade points_helper (grades): if the length of grades is zero then return 0.0 otherwise let x -the letter grade of the first course in the list let y - the of credits of the first course in the list if either x or y is invalid then return None let g- the grade point associated with x let r - sum of grade points of courses after the first course if r is None: return None otherwise: return the sum y g r Pseudocode for top-level function: def gpa_calculator (grades): return grade_points_helper (grades) credit_sum helper (grades) The pseudocode for gpa calculator is actually incomplete. There are some error cases you will have to Examples: Function Call gpa.calculator('A, 4.'B', 4, 'A,4 gpa.calculator('A', 4, 'Q, 3, 'C', 1, F, 21) None gpa.calculator ()) Return Value 3.666 0.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
