Advertisement
veronikaaa86

03. Histogram

Jul 24th, 2022
1,221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 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.     current_num = int(input())
  10.  
  11.     if current_num < 200:
  12.         p1 = p1 + 1
  13.     elif current_num <= 399:
  14.         p2 = p2 + 1
  15.     elif current_num <= 599:
  16.         p3 = p3 + 1
  17.     elif current_num <= 799:
  18.         p4 = p4 + 1
  19.     else:
  20.         p5 = p5 + 1
  21.  
  22. percent_p1 = p1 / n * 100
  23. print(f"{percent_p1:.2f}%")
  24. percent_p2 = p2 / n * 100
  25. print(f"{percent_p2:.2f}%")
  26. percent_p3 = p3 / n * 100
  27. print(f"{percent_p3:.2f}%")
  28. percent_p4 = p4 / n * 100
  29. print(f"{percent_p4:.2f}%")
  30. percent_p5 = p5 / n * 100
  31. print(f"{percent_p5:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement