Question: (Question 1) Write a function called count_divisibles that takes a list as input, and calculates the number of numbers divisible by some other number n

(Question 1) Write a function called count_divisibles that takes a list as input, and calculates the number of numbers divisible by some other number n.

Hint: This should be similar to count_evens, but more general (you're not calculating numbers divisible by 2, but some other number that can be specified in the function).

> count_divisibles([5, 10], n = 5) 2

(Question 2)

Write a function called trimmed_mean(nums, trim) that takes in a list of numbers (you may assume that the input is valid!), and an optional integer keyword argument trim (that takes on values of 0 or larger).

This function:

Removes the trim largest and smallest numbers from that list.

returns the arithmetic mean of whatever is left.

By default, trim = 1.

Example

trimmed_mean([2, 3, -100, 50000, 4]) would return 3, because 50000 and -100 are removed, and the mean of [2, 3, 4] is 3.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!