Learn

Great! Now we need to compute a student’s average using weighted averages.

cost = { "apples": [3.5, 2.4, 2.3], "bananas": [1.2, 1.8], } return 0.9 * average(cost["apples"]) + \ 0.1 * average(cost["bananas"])

- In the above example, we create a dictionary called
`cost`

that contains the costs of some fruit. - Then, we calculate the average cost of apples and the average cost of bananas. Since we like apples much more than we like bananas, we weight the average cost of apples by 90% and the average cost of bananas by 10%.

The `\`

character is a *continuation character*. The following line is considered a *continuation* of the current line.

### Instructions

**1.**

Write a function called `get_average`

that takes a student dictionary (like `lloyd`

, `alice`

, or `tyler`

) as input and `return`

s his/her weighted average.

- Define a function called
`get_average`

that takes one argument called`student`

. - Make a variable
`homework`

that stores the`average()`

of`student["homework"]`

. - Repeat the above step for “quizzes” and “tests”.
- Multiply the 3 averages by their weights and return the sum of those three. Homework is 10%, quizzes are 30% and tests are 60%.

# Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.