Advertisement
aneliabogeva

Histogram

May 20th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. n = int(input())
  2.  
  3. counter1 = 0
  4. counter2 = 0
  5. counter3 = 0
  6. counter4 = 0
  7. counter5 = 0
  8.  
  9. for i in range(1, n+1):
  10. num = int(input())
  11. if num < 200:
  12. counter1 +=1
  13. elif num >= 200 and num <= 399:
  14. counter2 +=1
  15. elif num >= 400 and num <= 599:
  16. counter3 +=1
  17. elif num >= 600 and num <= 799:
  18. counter4 +=1
  19. elif num >= 800:
  20. counter5 +=1
  21.  
  22. p1 = counter1 / n *100
  23. p2 = counter2 / n *100
  24. p3 = counter3 / n *100
  25. p4 = counter4 / n *100
  26. p5 = counter5 / n *100
  27.  
  28. print(f"{p1:.2f}%")
  29. print(f"{p2:.2f}%")
  30. print(f"{p3:.2f}%")
  31. print(f"{p4:.2f}%")
  32. print(f"{p5:.2f}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement