Question: Having trouble figuring out exactly how to write this program in Python. Write a file named gpa.py that computes a cumulative GPA using three functions:
Having trouble figuring out exactly how to write this program in Python.
Write a file named gpa.py that computes a cumulative GPA using three functions: add_course adds a new course to the running total, and gpa and credit_total gets your cumulative GPA and credit count, respectively. It uses two global variables to keep track of GPA and credits (both initially 0) . Invoking gpa.add_course(3.7, 3) should add a 3-credit course with GPA 3.7 to the running GPA and credit count total Invoking gpa.gpa() should retrieve your current total GPA. Invoking gpa.credit_total() should retrieve your current total credits earned Invoking gpa.add_course with only one argument (e.g., gpa. add_course(3.7)) should add a 3-credit course. None of the functions nor the file itself should print anything nor ask for any input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
