I would like calculate the final exam grade that a student may need to get their desired overall class score., given three inputs: the overall grade that they would have in the course IF they skipped the final and took the 0 (skipped_final), the final exam weight (final_weight), and the desired score that the student wants overall in the course. required_score is the final exam score I want to return. I included a test case below which says the student would need a 160% on the final to get a 90% overall, when they would actually only need an 87% on the final for this. Does anyone see an issue with my function?
def required_final_exam_score(skipped_final, final_weight, target_score):
final_weight_ratio = final_weight / 100
skipped_final_weight = 1 - final_weight_ratio
required_score = (target_score - (skipped_final * skipped_final_weight)) / final_weight_ratio
return required_score
skipped_final = 72.5
final_weight = float(input("Enter the final exam weight (in percentage): "))
target_score = float(input("Enter the target overall course grade: "))
required_score = required_final_exam_score(skipped_final, final_weight, target_score)
print("Required Final Exam Score:", required_score)
enter code here
Test case
Enter the final exam weight (in percentage): 20
Enter the target overall course grade: 90
Required Final Exam Score: 160.0
1