Advertisement
veronikaaa86

03. Histogram

May 29th, 2022
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. n = int(input())
  2.  
  3. p1 = 0
  4. p2 = 0
  5. p3 = 0
  6. p4 = 0
  7. p5 = 0
  8. for i in range(1, n + 1):
  9. currentNum = int(input())
  10.  
  11. if currentNum < 200:
  12. p1 = p1 + 1
  13. elif currentNum <= 399:
  14. p2 = p2 + 1
  15. elif currentNum <= 599:
  16. p3 = p3 + 1
  17. elif currentNum <= 799:
  18. p4 = p4 + 1
  19. else:
  20. p5 = p5 + 1
  21.  
  22. p1_percent = p1 / n * 100
  23. print(f"{p1_percent:.2f}%")
  24. p2_percent = p2 / n * 100
  25. print(f"{p2_percent:.2f}%")
  26. p3_percent = p3 / n * 100
  27. print(f"{p3_percent:.2f}%")
  28. p4_percent = p4 / n * 100
  29. print(f"{p4_percent:.2f}%")
  30. p5_percent = p5 / n * 100
  31. print(f"{p5_percent:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement