Advertisement
Guest User

XD

a guest
May 30th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.13 KB | None | 0 0
  1. #global variables
  2. name = ""
  3. allStudents = []
  4. classes = {"12A": [], "12B": [], "12C": []}
  5. scienceAll = []
  6. mathsAll = []
  7. englishAll = []
  8. namez = []
  9. mathsAllSorted = []
  10. scienceAllSorted = []
  11. englishAllSorted = []
  12. findex = []
  13. def addNewClass():
  14.     whatClass1 = input("Please input the name of the class that you want to add to the classes")
  15.  
  16.     if whatClass1 in classes.keys():
  17.         print("That class is already made")
  18.         addNewClass()
  19.     else:
  20.         classes[whatClass1] = []
  21.         print("The classes there are right now is:", classes)
  22.  
  23.  
  24. def printAllStudents():
  25.     global allStudents
  26.     global student
  27.     print("Every student that is enrolled:")
  28.     for p in range(len(allStudents)):
  29.         print(allStudents[p].printName())
  30.  
  31.  
  32. def lowestToHighest():
  33.     global findex
  34.     global scienceAllSorted
  35.     global englishAllSorted
  36.     global mathsAllSorted
  37.     global namez
  38.     global scienceAll
  39.     global mathsAll
  40.     global englishAll
  41.     global student
  42.     global allStudents
  43.     mathsAllSorted.sort()
  44.     scienceAllSorted.sort()
  45.     englishAllSorted.sort()
  46.     findex = []
  47.  
  48.     while True:
  49.         while True:
  50.             try:
  51.                 htlInput = int(input("What course would you like to check the grades of from highest to lowest  \n 1) Maths \n 2) Science \n 3) English \n "))
  52.                 break
  53.             except ValueError:
  54.                 print("Please input a number")
  55.         if htlInput == 1:
  56.             print("Lowest To Highest for Maths results:")
  57.             for i in mathsAllSorted:
  58.                 findex.append(mathsAll.index(i))
  59.             for i in findex:
  60.                 print(namez[i],mathsAll[i])
  61.  
  62.             break
  63.         elif htlInput == 2:
  64.             print("Lowest To Highest for Science:")
  65.             for i in scienceAllSorted:
  66.                 findex.append(scienceAll.index(i))
  67.             for i in findex:
  68.                 print(namez[i],scienceAll[i])
  69.             break
  70.  
  71.         elif htlInput == 3:
  72.             print("Lowest To Highest for English")
  73.             for i in englishAllSorted:
  74.                 findex.append(englishAll.index(i))
  75.             for i in findex:
  76.                 print(namez[i],englishAll[i])
  77.             break
  78.         else:
  79.             print("Please input 1,2 or 3")
  80.  
  81.  
  82. class Student:
  83.  
  84.     name = ""
  85.     age = 0
  86.     science = 0
  87.     maths = 0
  88.     english = 0
  89.     def __init__(self,name,age,science,maths,english):
  90.         self.name = name
  91.         self.age = age
  92.         self.science = science
  93.         self.maths = maths
  94.         self.english = english
  95.         print("Name is", self.name)
  96.         print("Age is", self.age)
  97.         print("Science result is", self.science)
  98.         print("Maths result is", self.maths)
  99.         print("English result is" , self.english)
  100.  
  101.     def average(self):
  102.         self.Averagenum = (self.science + self.maths + self.english) / 3
  103.         print("The average is",self.Averagenum)
  104.  
  105.     def printName(self):
  106.         return self.name
  107.     def printScience(self):
  108.         return self.science
  109.     def printMaths(self):
  110.         return self.maths
  111.  
  112.     def printEnglish(self):
  113.         return self.english
  114.  
  115.  
  116.  
  117. def mainFunct():
  118.     global englishAllSorted
  119.     global scienceAllSorted
  120.     global mathsAllSorted
  121.     global namez
  122.     global allStudents
  123.     global findex
  124.     subBool = True
  125.     workClass = []
  126.     global classes
  127.     dictStudent = []
  128.     mainBool = True
  129.     global scienceAll
  130.     global mathsAll
  131.     global englishAll
  132.     newAllStudents = []
  133.  
  134.     loopBool = True
  135.     while mainBool == True:
  136.  
  137.         print("Welcome to Raf's Student Grade Book")
  138.         while True:
  139.             try:
  140.                 menu = int(input(" 1) Add a new student to a class \n 2) Add a new class \n 3) List of all the students enrolled \n 4) Lowest to Highest \n 5) add new marks \n 6) Change"))
  141.                 break
  142.             except ValueError:
  143.                 print("Please enter in a number")
  144.  
  145.         if menu == 1:
  146.  
  147.             name = input("What is their name")
  148.             while True:
  149.  
  150.                 try:
  151.  
  152.                     age = int(input("What is their age"))
  153.                     break
  154.                 except ValueError:
  155.                     print("Ages only contain letters...")
  156.  
  157.  
  158.             while loopBool == True:
  159.                 while True:
  160.                     try:
  161.                         science = int(input("What was their science result out of 100"))
  162.                         break
  163.                     except ValueError:
  164.                         print("Sciene Results only contains letters...")
  165.                 if science <= 100:
  166.                     loopBool = False
  167.                 else:
  168.                     print("The science results is /100")
  169.  
  170.             loopBool = True
  171.  
  172.             while loopBool == True:
  173.                 while True:
  174.                     try:
  175.                         maths = int(input("What was their maths result out of 100"))
  176.                         break
  177.                     except ValueError:
  178.                         print("Maths Results only contain letters...")
  179.                 if maths <= 100:
  180.                     loopBool = False
  181.                 else:
  182.                     print("The maths results are /100")
  183.             loopBool = True
  184.  
  185.             while loopBool == True:
  186.                 while True:
  187.                     try:
  188.                         english = int(input("What was their english result out of 100"))
  189.                         break
  190.                     except ValueError:
  191.                         print("English results usuallly only contain letters...")
  192.                 if english <= 100:
  193.                     loopBool = False
  194.                 else:
  195.                     print("THe english results is out of 100")
  196.  
  197.             loopBool = True
  198.  
  199.             student = Student(name,age,science,maths,english)
  200.             allStudents.append(student)
  201.             scienceAll.append(student.science)
  202.             mathsAll.append(student.maths)
  203.             englishAll.append(student.english)
  204.             namez.append(student.name)
  205.             mathsAllSorted = mathsAll[:]
  206.             scienceAllSorted = scienceAll[:]
  207.             englishAllSorted = englishAll[:]
  208.  
  209.  
  210.             subBool = True
  211.  
  212.             while subBool == True:
  213.                 #Put this here if yo uwant to display the amount of classes a little better:  classesInit = []
  214.  
  215.  
  216.                 whatClass = input("What class would you like to add a new student to:"+ str(classes.keys()))
  217.                 if whatClass in classes:
  218.                     classes[whatClass].append(name)
  219.                     print("The students in", whatClass, "is")
  220.                     for i in range(len(classes[whatClass])):
  221.                         print(classes[whatClass][i])
  222.                         subBool = False
  223.  
  224.                 else:
  225.                     print("Sorry there is no class called" + whatClass)
  226.  
  227.  
  228.  
  229.  
  230.         #elif statements
  231.  
  232.         elif menu == 2:
  233.             addNewClass()
  234.  
  235.         elif menu == 3:
  236.             printAllStudents()
  237.  
  238.         elif menu == 4:
  239.             lowestToHighest()
  240.         else:
  241.             print("Please select either 1,2,3,4 or 5")
  242.  
  243.  
  244. mainFunct()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement