Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 05. Game Of Intervals
- gameturns = int(input())
- sum = 0
- one = 0
- two = 0
- three = 0
- four = 0
- five = 0
- invalid = 0
- i = 1
- while i <= gameturns:
- nums_to_check = int(input())
- if nums_to_check < 0 or nums_to_check > 50:
- sum /= 2
- invalid += 1
- elif nums_to_check <= 9:
- sum = sum + (0.2 * nums_to_check)
- one += 1
- elif nums_to_check <= 19:
- sum = sum + (0.3 * nums_to_check)
- two += 1
- elif nums_to_check <= 29:
- sum = sum + (0.4 * nums_to_check)
- three += 1
- elif nums_to_check <= 39:
- sum += 50
- four += 1
- elif nums_to_check <= 50:
- sum += 100
- five += 1
- i += 1
- resultOne = (one / gameturns) * 100
- resultTwo = (two / gameturns) * 100
- resultThree = (three / gameturns) * 100
- resultFour = (four / gameturns) * 100
- resultFive = (five / gameturns) * 100
- resultInvalid = (invalid / gameturns) * 100
- print(f"{sum:.2f}")
- print(f"From 0 to 9: {resultOne:.2f}%")
- print(f"From 10 to 19: {resultTwo:.2f}%")
- print(f"From 20 to 29: {resultThree:.2f}%")
- print(f"From 30 to 39: {resultFour:.2f}%")
- print(f"From 40 to 50: {resultFive:.2f}%")
- print(f"Invalid numbers: {resultInvalid:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement