Don't like ads? PRO users don't see any ads ;-)
Guest

5.2

By: dvdjaco on Feb 21st, 2012  |  syntax: Python  |  size: 0.41 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # #!/usr/bin/python
  2. #
  3. # By dvdjaco
  4. # Exercise 5.2
  5. #
  6. # Write another program that prompts for a list of numbers as above and at the end
  7. # prints out both the maximum and minimum of the numbers instead of the average.
  8.  
  9. l = list()
  10.  
  11. while True:
  12.         num = (raw_input("Enter a number: "))
  13.         if num == 'done' : break
  14.         try:
  15.                 l.append(float(num))           
  16.         except:
  17.                 print "Invalid input"
  18.  
  19. print max(l), min(l)