Question: Write a function total_numbers(number_list,weights) that takes a list of numbers and their weights and returns the weighted total of the numbers. Think about what needs
Write a function total_numbers(number_list,weights) that takes a list of numbers and their weights and returns the weighted total of the numbers. Think about what needs to happen before using a loop, during the loop, and after the loop finishes. In this question you are required to use a for loop, and not allowed to use the sum function. If the numbers are [1,2,3] and the weights are [.1,.5,.4] then the weighted total should be 1 * .1 + 2 * .5 + 3 * .4 = 2.3
For example:
| Test | Result |
|---|---|
| print(round(total_numbers([1,2,3],[.1,.5,.4]),1)) | 2.3 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
