Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function weighted_grade () that computes the weighted average of a series of user-entered grades. The function should (1) repeatedly ask the user for
Write a function weighted_grade () that computes the weighted average of a series of user-entered grades. The function should (1) repeatedly ask the user for a grade and a corresponding weight until they enter the empty string, (2) compute the weighted average of the entered grades, (3) print the result. Lig;W; The formula for a weighted average with grades g and weights w is , , In other words, the weighted average is the sum of each weight multiplied by each grade, divided by the sum of weights. This example shows the correct behavior of the function: >>> weighted_grade () Enter a grade: 90 Enter a weight: 3 Enter a grade: 100 Enter a weight: 2 Enter a grade: Your weighted grade is 94. This is correct because (90 3 + 100 2)/(3 + 2) = 94. Note that once the user enters the empty string for a grade, the function immediately prints the final result and does not ask for another weight. You can assume that the user will enter positive numeric values with or without decimals for both grades and weights. You can also assume that the user will enter at least one grade and weight pair
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started