Advertisement
BbJLeB

05. Game Of Intervals

May 31st, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. # 05. Game Of Intervals
  2.  
  3. gameturns = int(input())
  4. sum = 0
  5. one = 0
  6. two = 0
  7. three = 0
  8. four = 0
  9. five = 0
  10. invalid = 0
  11. i = 1
  12. while i <= gameturns:
  13.     nums_to_check = int(input())
  14.     if nums_to_check < 0 or nums_to_check > 50:
  15.         sum /= 2
  16.         invalid += 1
  17.     elif nums_to_check <= 9:
  18.         sum = sum + (0.2 * nums_to_check)
  19.         one += 1
  20.     elif nums_to_check <= 19:
  21.         sum = sum + (0.3 * nums_to_check)
  22.         two += 1
  23.     elif nums_to_check <= 29:
  24.         sum = sum + (0.4 * nums_to_check)
  25.         three += 1
  26.     elif nums_to_check <= 39:
  27.         sum += 50
  28.         four += 1
  29.     elif nums_to_check <= 50:
  30.         sum += 100
  31.         five += 1
  32.     i += 1
  33. resultOne = (one / gameturns) * 100
  34. resultTwo = (two / gameturns) * 100
  35. resultThree = (three / gameturns) * 100
  36. resultFour = (four / gameturns) * 100
  37. resultFive = (five / gameturns) * 100
  38. resultInvalid = (invalid / gameturns) * 100
  39. print(f"{sum:.2f}")
  40. print(f"From 0 to 9: {resultOne:.2f}%")
  41. print(f"From 10 to 19: {resultTwo:.2f}%")
  42. print(f"From 20 to 29: {resultThree:.2f}%")
  43. print(f"From 30 to 39: {resultFour:.2f}%")
  44. print(f"From 40 to 50: {resultFive:.2f}%")
  45. print(f"Invalid numbers: {resultInvalid:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement