Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. count = 0
  2. category1 = 0
  3. category2 = 0
  4. category3 = 0
  5. category4 = 0
  6. ended = False
  7.  
  8. while not ended:
  9.   mark=input("Enter a mark: ")
  10.   mark=int(mark)
  11.  
  12.   if mark == -1:
  13.     ended=True
  14.  
  15.   elif mark >= 70 and mark <= 100:
  16.     category4 += 1
  17.   elif mark >= 40 and mark <= 69:
  18.     category3 += 1
  19.   elif mark >= 30 and mark <=39:
  20.     category2 +=1
  21.   elif mark >= 0 and mark <=29:
  22.     category1 +=1
  23.  
  24.   else:
  25.      print("Wrong number. Try again.")
  26.  
  27. maxSize = max(category1,category2,category3,category4)
  28.  
  29. for i in range(maxSize, 0, -1):
  30.     currentLine = ""
  31.     for j in range(0,5):
  32.  
  33.         if j == 0:
  34.             currentLine += "{0:2}|".format(i)
  35.  
  36.         else:
  37.             categoryAmount = 0
  38.             if j == 1:
  39.                 categoryAmount = category1
  40.             elif j == 2:
  41.                 categoryAmount = category2
  42.             elif j == 3:
  43.                 categoryAmount = category3
  44.             else:
  45.                 categoryAmount = category4
  46.  
  47.             sign = " "
  48.             if categoryAmount >= i:
  49.                 sign = "■"
  50.  
  51.             currentLine += " {:^11}".format(sign)
  52.  
  53.     print(currentLine)
  54.  
  55. print("   {0:^11} {1:^11} {2:^11} {3:^11}"
  56.       .format("category1","category2","category3","category4"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement