Advertisement
Guest User

14.02.2023

a guest
Feb 13th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. largest = None
  2. smallest = None
  3.  
  4. while True:
  5.     i = input('Enter the number. If you are finished -- print "done" ')
  6.     if i == "done":
  7.         break
  8.     try:
  9.         int(i)
  10.         if smallest is None or smallest > i:
  11.             smallest = i
  12.         if largest is None or largest < i:
  13.             largest = i
  14.     except:
  15.         print('Please, enter the number')
  16.         continue
  17.  
  18. print('Largest:', largest)
  19. print('Smallest:', smallest)
  20.  
  21. """
  22. вывод-ввод:
  23. Enter the number. If you are finished -- print "done" 1
  24. Enter the number. If you are finished -- print "done" 2
  25. Enter the number. If you are finished -- print "done" 3
  26. Enter the number. If you are finished -- print "done" 4
  27. Enter the number. If you are finished -- print "done" 5
  28. Enter the number. If you are finished -- print "done" 10
  29. Enter the number. If you are finished -- print "done" 100
  30. Enter the number. If you are finished -- print "done" 100000
  31. Enter the number. If you are finished -- print "done" 200000
  32. Enter the number. If you are finished -- print "done" -10000
  33. Enter the number. If you are finished -- print "done" done
  34. Largest: 5
  35. Smallest: -10000
  36.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement