Advertisement
Guest User

Untitled

a guest
May 20th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. classAlist=[]
  2. classBlist=[]
  3.  
  4. nameAlist=[]
  5. nameBlist=[]
  6. nameABlist=[]
  7.  
  8. scoreAlist=[]
  9. scoreBlist=[]
  10. markListAB=[]
  11. nameListAB=[]
  12. scoreListAB=[]
  13. bottom_score = 0
  14. top_score = 100
  15. count=0
  16. import sys
  17. global count
  18.  
  19. def addListAB():
  20. nameListAB.append(name)
  21. markListAB.append(mark)
  22.  
  23. #----------------------------------------------------------------------------------------------------------------
  24.  
  25. def Average():
  26. average = sum(markListAB)/len(markListAB)
  27. print("The average mark of both classes is :",average)
  28.  
  29. #----------------------------------------------------------------------------------------------------------------
  30.  
  31. def Top3():
  32. top3A = sorted(zip(classAlist,nameAlist))[:3]
  33. top3B = sorted(zip(classBlist,nameBlist))[:3]
  34. print("Top three in A is :", top3A)
  35. print("Top three in B is :", top3B)
  36.  
  37. #----------------------------------------------------------------------------------------------------------------
  38.  
  39. def deletionA():
  40. whichone=str(input("Which name would you like to delete?")).lower()
  41. scoreremove=int(input("Please enter the corressponding score too"))
  42. deleteAname()
  43. deleteAscore()
  44.  
  45. def deletionB():
  46. whichone2=str(input("Which name would you like to delete?")).lower()
  47. scoreremove2=int(input("Please enter the corressponding score too"))
  48. deleteBname()
  49. deleteBscore()
  50. #-------------------------------------------------------------------------------------------------------------
  51.  
  52.  
  53. def enter():
  54. illegalScore = mark > top_score or mark < bottom_score
  55. EXCELLENCE = 80
  56. MERIT = 60
  57. ACHIEVED = 40
  58. if illegalScore:
  59. print(mark,"is not a legal exam score")
  60. else:
  61. if mark >= EXCELLENCE:
  62. print("Mark of ", mark, " : Excellent")
  63.  
  64. elif mark >= MERIT:
  65. print("Mark of ", mark, " : Merit")
  66.  
  67. elif mark >= ACHIEVED:
  68. print("Mark of ", mark, " : Achieved")
  69.  
  70. elif mark < ACHIEVED and mark > 0:
  71. print("Mark of ", mark, " : Not Achieved")
  72.  
  73. else:
  74. print("Mark of ",mark, " : Absent")
  75.  
  76.  
  77.  
  78. #-------------------------------------------------------------------------------------------------------------
  79.  
  80. def deleteAname():
  81. try:
  82. nameAlist.remove(whichone)
  83. except ValueError:
  84. pass
  85.  
  86. def deleteAscore():
  87. try:
  88. classAlist.remove(scoreremove)
  89. except ValueError:
  90. pass
  91.  
  92. def deleteBname():
  93. try:
  94. nameBlist.remove(whichone2)
  95. except ValueError:
  96. pass
  97.  
  98. def deleteBscore():
  99. try:
  100. classBlist.remove(scoreremove2)
  101. except ValueError:
  102. pass
  103. #-------------------------------------------------------------------------------------------------------------
  104.  
  105.  
  106. def addingtolistA():
  107. classAlist.append(grade)
  108. nameAlist.append(name)
  109. scoreAlist.append(mark)
  110. def addingtolistB():
  111. classBlist.append(grade)
  112. nameBlist.append(name)
  113. scoreBlist.append(mark)
  114.  
  115. #-------------------------------------------------------------------------------------------------------------
  116.  
  117. def inputs():
  118. global name, score, mark, classs, grade
  119. classs=str(input("Please enter the student's class (a or b) or press enter to go to deletion")).lower()
  120. if classs=="a":
  121. try:
  122. name=(input("Please enter the name of the student"))
  123. mark = int(input("What was your exam mark? "))
  124. except Value error:
  125. print ("not a number please enter a valid response!!")
  126. grade=mark
  127. enter()
  128. addListAB()
  129.  
  130. addingtolistA()
  131. print ("class A:",nameAlist)
  132. print ("class A:",classAlist)
  133.  
  134.  
  135. if classs=="b":
  136. name=(input("Please enter the name of the student"))
  137. mark = int(input("What was your exam mark? "))
  138. grade=mark
  139. enter()
  140. addingtolistB()
  141. addListAB()
  142.  
  143. print ("class B:",nameBlist)
  144. print ("class B:",classBlist)
  145.  
  146. answer=""
  147. answer=str(input("Would you like to put in another student?(Yes or No) or press enter to go to deletion"))
  148.  
  149.  
  150.  
  151. if answer=="yes":
  152. inputs()
  153. if answer=="no":
  154. print ("Thanks for entering in your names!")
  155.  
  156.  
  157.  
  158. #-------------------------------------------------------------------------------------------------------------
  159.  
  160.  
  161. answer=""
  162. answer=str(input("Would you like to put in a new student?(type Yes or press anything else to end the program)"))
  163. if answer=="yes":
  164. inputs()
  165. else:
  166. print ("Thanks for using this program!")
  167. response=str(input("Would you like to delete a value? Yes/No")).lower()
  168.  
  169. if response =="no":
  170. Average()
  171. Top3()
  172. classresponse=str(input("What class is the person from? a/b")).lower()
  173.  
  174.  
  175.  
  176. if classresponse=="a" and response=="yes":
  177. deletionA()
  178. print (nameAlist)
  179. print (classAlist)
  180.  
  181. if classresponse=="b" and response=="yes":
  182. deletionB()
  183. print (nameBlist)
  184. print (classBlist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement