Advertisement
Spocoman

05. Game Of Intervals

Dec 26th, 2021 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. num = int(input())
  2. result = 0
  3. num0To10 = 0
  4. num10To20 = 0
  5. num20To30 = 0
  6. num30To40 = 0
  7. num40To50 = 0
  8. invalid_num = 0
  9.  
  10. for i in range(num):
  11.     number = float(input())
  12.     if 0 <= number < 10:
  13.         result += number * 0.2
  14.         num0To10 += 1
  15.     elif 10 <= number < 20:
  16.         result += number * 0.3
  17.         num10To20 += 1
  18.     elif 20 <= number < 30:
  19.         result += number * 0.4
  20.         num20To30 += 1
  21.     elif 30 <= number < 40:
  22.         result += 50
  23.         num30To40 += 1
  24.     elif 40 <= number <= 50:
  25.         result += 100
  26.         num40To50 += 1
  27.     else:
  28.         result /= 2
  29.         invalid_num += 1
  30.  
  31. print(f'{result:.2f}')
  32. print(f'From 0 to 9: {num0To10 / num * 100:.2f}%')
  33. print(f'From 10 to 19: {num10To20 / num * 100:.2f}%')
  34. print(f'From 20 to 29: {num20To30 / num * 100:.2f}%')
  35. print(f'From 30 to 39: {num30To40 / num * 100:.2f}%')
  36. print(f'From 40 to 50: {num40To50 / num * 100:.2f}%')
  37. print(f'Invalid numbers: {invalid_num / num * 100:.2f}%')
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement