Advertisement
veronikaaa86

03. Histogram

Oct 2nd, 2022
1,330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. n = int(input())
  2.  
  3. p_1 = 0
  4. p_2 = 0
  5. p_3 = 0
  6. p_4 = 0
  7. p_5 = 0
  8. for i in range(1, n + 1):
  9.     current_num = int(input())
  10.  
  11.     if current_num < 200:
  12.         p_1 += 1
  13.     elif current_num <= 399:
  14.         p_2 += 1
  15.     elif current_num <= 599:
  16.         p_3 += 1
  17.     elif current_num <= 799:
  18.         p_4 += 1
  19.     elif current_num >= 800:
  20.         p_5 += 1
  21.  
  22. percent_p1 = p_1 / n * 100
  23. print(f"{percent_p1:.2f}%")
  24. percent_p2 = p_2 / n * 100
  25. print(f"{percent_p2:.2f}%")
  26. percent_p3 = p_3 / n * 100
  27. print(f"{percent_p3:.2f}%")
  28. percent_p4 = p_4 / n * 100
  29. print(f"{percent_p4:.2f}%")
  30. percent_p5 = p_5 / n * 100
  31. print(f"{percent_p5:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement