Given an array of numbers, return the difference between the largest and smallest values.
For example:
[23, 3, 19, 21, 16]
should return 20 (i.e., 23 - 3).
[1, 434, 555, 34, 112]
should return 554 (i.e., 555 - 1).
The array will contain a minimum of two elements. Input data range guarantees that max-min will cause no integer overflow.
def between_extremes(numbers):
#Your code goes here!
pass
def between_extremes(numbers):
return max(numbers) - min(numbers)
def between_extremes(numbers):
max = None
min = None
for n in numbers:
if max is None:
max = n
min = n
elif n > max:
max = n
elif n < min:
min = n
return max - min