← Back to challenges

Is the Average of All Elements a Whole Number?

PythonHardmatharraysvalidationloops

Instructions

Create a function that takes a list as an argument and returns True or False depending on whether the average of all elements in the list is a whole number or not.

Examples

is_avg_whole([1, 3]) ➞ True

is_avg_whole([1, 2, 3, 4]) ➞ False

is_avg_whole([1, 5, 6]) ➞ True

is_avg_whole([1, 1, 1]) ➞ True

is_avg_whole([9, 2, 2, 5]) ➞ False

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Convert Number to Corresponding Month Name