simeonshopov

Game of Invervals

Oct 16th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. n = int(input())
  2. points = 0
  3. p1 = 0
  4. p2 = 0
  5. p3 = 0
  6. p4 = 0
  7. p5 = 0
  8. invalids = 0
  9.  
  10. for i in range(n):
  11.   num = int(input())
  12.   if num < 0 or num > 50:
  13.     invalids += 1
  14.     points /= 2
  15.   elif 0 <= num <= 9:
  16.     p1 += 1
  17.     points += num * 0.2
  18.   elif 10 <= num <= 19:
  19.     p2 += 1
  20.     points += num * 0.3
  21.   elif 20 <= num <= 29:
  22.     p3 += 1
  23.     points += num * 0.4
  24.   elif 30 <= num <= 39:
  25.     p4 += 1
  26.     points += 50
  27.   elif 40 <= num <= 50:
  28.     p5 += 1
  29.     points += 100
  30.    
  31. print(f"{points:.2f}")
  32. print(f"From 0 to 9: {((p1 / n) * 100):.2f}%")
  33. print(f"From 10 to 19: {((p2 / n) * 100):.2f}%")
  34. print(f"From 20 to 29: {((p3 / n) * 100):.2f}%")
  35. print(f"From 30 to 39: {((p4 / n) * 100):.2f}%")
  36. print(f"From 40 to 50: {((p5 / n) * 100):.2f}%")
  37. print(f"Invalid numbers: {((invalids / n) * 100):.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment