66.0k views
0 votes
The user is able to input grades and their weights, and calculates the overall final mark. The program should also output what you need to achieve on a specific assessment to achieve a desired overall mark. The program should be able to account for MULTIPLE COURSES as well.

I have done some pseudocode. So to double check, please provide pseudocode and python code.
I do plan to use homework, quizzes and tests for the grades portion and using the exam as part of the desired mark portion.

Please follow the instructions above. LISTS are allowed to be used.

User Lukszar
by
7.3k points

1 Answer

5 votes

Answer:

def calculate_final_mark(courses):

final_mark = 0

total_weight = 0

for course in courses:

final_mark += course['mark'] * course['weight']

total_weight += course['weight']

return final_mark / total_weight

def calculate_required_mark(courses, desired_mark):

current_mark = calculate_final_mark(courses)

total_weight = 0

for course in courses:

total_weight += course['weight']

required_mark = (desired_mark - current_mark) / (1 - total_weight)

return required_mark

# Example usage:

courses = [

{'name': 'Math', 'mark': 80, 'weight': 0.4},

{'name': 'Science', 'mark': 70, 'weight': 0.3},

{'name': 'English', 'mark': 65, 'weight': 0.3},

]

final_mark = calculate_final_mark(courses)

print(f"Your final mark is {final_mark:.1f}")

desired_mark = 80

required_mark = calculate_required_mark(courses, desired_mark)

print(f"You need to score at least {required_mark:.1f} on your next assessment to achieve a final mark of {desired_mark}")

User Mark Ransom
by
7.8k points