57.4k views
4 votes
Design an algorithm to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format: testscore1 weight1 ... For example, the sample data is as follows: 75 0.20 95 0.35 85 0.15 65 0.30 The user is supposed to enter the data and press a Calculate button. The program must display the weighted average.

1 Answer

1 vote

Answer:

data = [75, 0.2, 95, 0.35, 85, 0.15]

print (f'Average weight: {sum(data) / len(data)}')

Step-by-step explanation:

This is python algorithm for finding average weight. To get average weight, you sum up all data involved and divide that amount by the number of data provided.

User Mohit Charadva
by
3.2k points