Weighted Average With np.average
Fenwick College builds a module grade from several assessed pieces, and the pieces do not count equally. Each carries a weight set out in the module handbook, and the grade is the weighted average of the pieces — a figure on the same 0-to-100 scale as the pieces themselves, so it can be read against them. The weights are whatever the handbook says. They are not required to be fractions and they are not required to come to any particular total, so the grade has to be shared out in proportion to them rather than assuming they already add up to one.
Task: Print the module grade: the weighted average of the assessed pieces.
Input
Three lines. The first holds a single integer n, the number of assessed pieces. The second holds the n scores on one line, separated by single spaces. The third holds the n weights, in the same piece order. Every weight is above zero.
Output
One line holding the grade with exactly two digits after the decimal point.
Example:
Input:
3
80 90 70
0.5 0.3 0.2
Output:
81.00
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in