Skip to content

Instantly share code, notes, and snippets.

@RaMSFT
Created October 12, 2022 06:56
Show Gist options
  • Select an option

  • Save RaMSFT/1b42a045f8c18bf8b77c6556bfa5a4a9 to your computer and use it in GitHub Desktop.

Select an option

Save RaMSFT/1b42a045f8c18bf8b77c6556bfa5a4a9 to your computer and use it in GitHub Desktop.
def difference_max_min(lst):
"""Find the difference between largest and smallest numbers from a list
Args:
lst (numerics): a list of numbers
Returns:
number: difference between largest and smallest numbers of the list
"""
smallest = min(lst)
largest = max(lst)
diff = largest - smallest
return diff
print(difference_max_min([10, 4, 1, 4, -10, -50, 32, 21]) )
print(difference_max_min([44, 32, 86, 19]) )
print(difference_max_min([34, 15, 88, 2]))
print(difference_max_min([34, -345, -1, 100]) )
print(difference_max_min([-76, 1.345, 1, 0]) )
print(difference_max_min([0.4356, 0.8795, 0.5435, -0.9999]) )
print(difference_max_min([7, 7, 7]) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment