Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 8 : Weighted Means In this problem, we will create a function named mean ( ) that can be used to calculate either standard

Problem 8: Weighted Means
In this problem, we will create a function named mean() that can be used to calculate either standard means or weighted
means. The function will have two parameters, x and w. The parameter x is expected to be a numerical list, and w is
expected to be either a numerical list or to have the value None. If w=None, then the function should simply return the
mean (or average) of the elements in x. If w is a list, then the function should return the weighted mean of the elements in
x, using the elements of w as weights.
If the elements of x are denoted by 0,1,..., and the elements of w are denoted by 0,1,...,, then the weighted
mean is calculated as follows:
00+11++
0+1++
As an example (that you are not being asked to include in your notebook), if:
list1=[200,400,100]
list2=[3,2,5]
3(200)+2(400)+5(100)1900
Then weighted_mean(list1, list2) should return: ==190
3+2+5
10
5
\
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is a purchase requisition?

Answered: 1 week ago