vivaladiva

Untitled

Oct 27th, 2020 (edited)
588
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Takes list of numbers as a parameter.
  2. # Returns smallest and largest values.
  3. def min_max(l):
  4.     l.sort()
  5.     return (l[0], l[-1])
  6.  
  7.  
  8. # Tests
  9.  
  10. # With list of integers
  11. print("Min and Max", min_max([1, 5, 3, 1, 4, 2, 3]))
  12.  
  13. # With list of floats
  14. print("Min and Max", min_max([1.2, 5.06, 3.5, 1.1, 4.0, 2.9874, 3.33]))
  15.  
  16. # With list of strings (names)
  17. print("Min and Max", min_max(['Homer', 'Marge', 'Bart', 'Lisa']))
RAW Paste Data