Advertisement
Spocoman

02. Number Definer

Jan 12th, 2022
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. num = float(input())
  2. if num == 0:
  3.     print('zero')
  4. elif num > 0:
  5.     if num < 1:
  6.         print('small positive')
  7.     elif num > 1000000:
  8.         print('large positive')
  9.     else:
  10.         print('positive')
  11. else:
  12.     if abs(num) < 1:
  13.         print('small negative')
  14.     elif abs(num) > 1000000:
  15.         print('large negative')
  16.     else:
  17.         print('negative')
  18.  
  19.  
  20. Решение с колекция:
  21.  
  22. n = float(input())
  23.  
  24. output = {n == 0: 'zero',
  25.           0 < n < 1: 'small positive',
  26.           1 <= n <= 1000000: 'positive',
  27.           n > 1000000: 'large positive',
  28.           0 > n > -1: 'small negative',
  29.           -1 >= n >= -1000000: 'negative',
  30.           n < -1000000: 'large negative'}
  31.  
  32. print(output[True])
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement