…
…
Convert letter grades to a 4.0 scale; calculate term averages and the overall GPA, find failed courses and the honors list, and print an aligned transcript.
Alex finished the first year of a computer science degree and has the grades for two terms. A transcript is needed for a scholarship application. The university uses a 4.0 scale: each letter grade has a value (A 4.0, B+ 3.5 ... F 0.0, in half-point steps to keep the arithmetic simple), and the average is weighted by the credits of the courses. In this project you will write Alex's grade calculator step by step.
What you will build: In the last step the program will print a transcript like this:
=== Fall 2025 ===
MATH101 Calculus I 6 C+ Passed
PHYS101 Physics I 6 F Failed
...
Average: 2.24 | Credits: 19/25 | Honors: None
=== Spring 2026 ===
...
Average: 3.20 | Credits: 28/28 | Honors: Honors
GPA: 3.10Along the way you will write functions for the weighted points of a course, the term average, the course status (Passed, Conditional, Failed), the honors list, the earned credits, and the overall GPA, which counts only the latest grade of a retaken course.
Lessons used: conditions (6–8), the for loop and accumulation patterns (10, 12–13), functions (14–16), string methods and formatting (21–22), lists (23–24), dictionaries and lists of records (26–28).
How to work: The grades are ready in the first cell. In each step you write a function and reuse it in the later steps; the cells share the same session, so do not move on to the next step without running the previous one. The check also tries your functions on course lists other than Alex's grades, so write code that calculates the result instead of typing it by hand.
What you'll do
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
Alex finished the first year of a computer science degree and has the grades for two terms. The university uses a 4.0 scale: each letter grade has a value (A 4.0 ... F 0.0, in half-point steps to keep the arithmetic simple). The values are in the GRADE_POINTS dictionary and the courses are in the terms dictionary: the key is the name of the term, the value is the list of that term's courses. Each course is a dictionary: code, name, credits, and letter grade.
The first piece of the average is the course's weighted points: credits × grade value. A student who gets a C+ (2.5) in a 6-credit course earns 15 points from it. This is why bigger courses affect the average more.
Write the function course_points(course). It takes the course dictionary and returns credits × grade value. You find the grade value by using the course's letter grade as a key in the GRADE_POINTS dictionary.
This step's code cell is for members.Sign up free
The term average is not the plain average of the grade values. You add up the weighted points of all courses and divide by the
Code cells are for members
You can read the steps. Sign up free to run the code, complete the steps and save your progress.
average = (credits₁ × value₁ + credits₂ × value₂ + ...) / (credits₁ + credits₂ + ...)
For example, a student with an A (4.0) in a 6-credit course and an F (0.0) in a 2-credit course has an average of (24 + 0) / 8 = 3.00, not 2.00, which is the plain average of the values.
term_average(courses) takes a list of courses, adds up the two totals in a loop, and returns the result rounded to two decimal places with round(..., 2). Use the course_points function from the previous step for the points.
This step's code cell is for members.Sign up free
Each letter grade also decides the status of the course. Alex's university has this rule:
| Letter grade | Status |
|---|---|
| A, B+, B, C+, C | Passed |
| D+, D | Conditional (may need a retake if the average is low) |
| D-, F | Failed |
Write the function status(grade) with if, elif, and else. Then, for each term, count the statuses in a dictionary: the key is the status, the value is the number of courses with that status. To count a key that is not in the dictionary yet, use the pattern counts.get(key, 0) + 1.
This step's code cell is for members.Sign up free
At the end of the term, students with high results make the honors list. The rule:
1. A student with a Failed or Conditional course in the term is not on the list (whatever the average is).
2. A term average of 3.50 or above is "High honors".
3. An average from 3.00 to 3.49 is "Honors".
4. Otherwise "None".
Order matters: look at the course statuses first, and if even one course is not Passed, return "None" right away. A student with a 6-credit A and a 2-credit D has an average of 3.25, but the D keeps them off the honors list. The boundaries matter too: a student with exactly 3.00 makes the list.
This step's code cell is for members.Sign up free
Alex's advisor asks two things every term: "How many credits did you earn?" and "Which courses will you retake?"
Write two small functions. The report lines are ready: they join the codes with ", ".join(...) and print them on one line.
This step's code cell is for members.Sign up free
The overall GPA is calculated from the courses of all terms, but there is a catch: Alex got an F in PHYS101 in the fall, retook it in the spring, and passed with a C. In a retaken course the latest grade counts; the old F does not enter the average again. If you count both grades, the course's credits are counted twice and the average drops unfairly.
Use the dictionary property that assigning to the same key again overwrites the old value: go through the terms in order and put each course into the dictionary with latest[course["code"]] = course. A course with the same code in a later term replaces the earlier one. When the loop ends, the values of the dictionary are the final version of each course; calculate the average from them with term_average.
This step's code cell is for members.Sign up free
The last job is the transcript Alex will attach to a scholarship application: for each term a heading, the courses in aligned columns, and the term summary below; at the very end the overall GPA.
Column widths: code 8 characters left-aligned, course name 24 characters left-aligned, credits 2 characters right-aligned, two spaces, letter grade 4 characters left-aligned, then the status. Averages are always written with two decimals (:.2f). You get all the pieces from the functions of the previous steps; there is no calculation in this step, only formatting.
This step's code cell is for members.Sign up free