grade.needed_to_pass
grade.needed_to_pass(course_type, grades)Compute the minimum equal grade needed on all remaining components to pass (>= 60%).
The function supports two grading schemes:
- quiz: 4 labs (12.5% each) and 2 quizzes (25% each)
- project: 4 milestones (20% each) and 4 individual assignments (5% each)
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| course_type | str | Course grading scheme. Must be "quiz" or "project". |
required |
| grades | dict | Dictionary mapping completed component names to earned grades (0 - 100). Example: {"lab1": 80, "quiz1": 70} |
required |
Returns
| Name | Type | Description |
|---|---|---|
| dict | Dictionary mapping each remaining component to the minimum grade required on that component to reach at least 60%. The same minimum grade is applied to all remaining components. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If course_type is invalid. If a component name is unknown. If a grade is outside the range 0 - 100. If it is mathematically impossible to pass. |
|
| TypeError | If grades is not a dictionary. If any key is not a string or value is not numeric. |
Examples
Quiz-based course with two labs and one quiz completed:
>>> needed_to_pass("quiz", {"lab1": 80, "lab2": 70, "quiz1": 60})
{'lab3': 52.5,
'lab4': 52.5,
'quiz2': 52.5}Project-based course with one milestone completed:
>>> needed_to_pass("project", {"Milestone1": 80})
{'Milestone2': 55.0,
'Milestone3': 55.0,
'Milestone4': 55.0,
'IndividualAssignment1': 55.0,
'IndividualAssignment2': 55.0,
'IndividualAssignment3': 55.0,
'IndividualAssignment4': 55.0}