Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #global variables
- name = ""
- allStudents = []
- classes = {"12A": [], "12B": [], "12C": []}
- scienceAll = []
- mathsAll = []
- englishAll = []
- namez = []
- mathsAllSorted = []
- scienceAllSorted = []
- englishAllSorted = []
- findex = []
- def addNewClass():
- whatClass1 = input("Please input the name of the class that you want to add to the classes")
- if whatClass1 in classes.keys():
- print("That class is already made")
- addNewClass()
- else:
- classes[whatClass1] = []
- print("The classes there are right now is:", classes)
- def printAllStudents():
- global allStudents
- global student
- print("Every student that is enrolled:")
- for p in range(len(allStudents)):
- print(allStudents[p].printName())
- def lowestToHighest():
- global findex
- global scienceAllSorted
- global englishAllSorted
- global mathsAllSorted
- global namez
- global scienceAll
- global mathsAll
- global englishAll
- global student
- global allStudents
- mathsAllSorted.sort()
- scienceAllSorted.sort()
- englishAllSorted.sort()
- findex = []
- while True:
- while True:
- try:
- 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 "))
- break
- except ValueError:
- print("Please input a number")
- if htlInput == 1:
- print("Lowest To Highest for Maths results:")
- for i in mathsAllSorted:
- findex.append(mathsAll.index(i))
- for i in findex:
- print(namez[i],mathsAll[i])
- break
- elif htlInput == 2:
- print("Lowest To Highest for Science:")
- for i in scienceAllSorted:
- findex.append(scienceAll.index(i))
- for i in findex:
- print(namez[i],scienceAll[i])
- break
- elif htlInput == 3:
- print("Lowest To Highest for English")
- for i in englishAllSorted:
- findex.append(englishAll.index(i))
- for i in findex:
- print(namez[i],englishAll[i])
- break
- else:
- print("Please input 1,2 or 3")
- class Student:
- name = ""
- age = 0
- science = 0
- maths = 0
- english = 0
- def __init__(self,name,age,science,maths,english):
- self.name = name
- self.age = age
- self.science = science
- self.maths = maths
- self.english = english
- print("Name is", self.name)
- print("Age is", self.age)
- print("Science result is", self.science)
- print("Maths result is", self.maths)
- print("English result is" , self.english)
- def average(self):
- self.Averagenum = (self.science + self.maths + self.english) / 3
- print("The average is",self.Averagenum)
- def printName(self):
- return self.name
- def printScience(self):
- return self.science
- def printMaths(self):
- return self.maths
- def printEnglish(self):
- return self.english
- def mainFunct():
- global englishAllSorted
- global scienceAllSorted
- global mathsAllSorted
- global namez
- global allStudents
- global findex
- subBool = True
- workClass = []
- global classes
- dictStudent = []
- mainBool = True
- global scienceAll
- global mathsAll
- global englishAll
- newAllStudents = []
- loopBool = True
- while mainBool == True:
- print("Welcome to Raf's Student Grade Book")
- while True:
- try:
- 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"))
- break
- except ValueError:
- print("Please enter in a number")
- if menu == 1:
- name = input("What is their name")
- while True:
- try:
- age = int(input("What is their age"))
- break
- except ValueError:
- print("Ages only contain letters...")
- while loopBool == True:
- while True:
- try:
- science = int(input("What was their science result out of 100"))
- break
- except ValueError:
- print("Sciene Results only contains letters...")
- if science <= 100:
- loopBool = False
- else:
- print("The science results is /100")
- loopBool = True
- while loopBool == True:
- while True:
- try:
- maths = int(input("What was their maths result out of 100"))
- break
- except ValueError:
- print("Maths Results only contain letters...")
- if maths <= 100:
- loopBool = False
- else:
- print("The maths results are /100")
- loopBool = True
- while loopBool == True:
- while True:
- try:
- english = int(input("What was their english result out of 100"))
- break
- except ValueError:
- print("English results usuallly only contain letters...")
- if english <= 100:
- loopBool = False
- else:
- print("THe english results is out of 100")
- loopBool = True
- student = Student(name,age,science,maths,english)
- allStudents.append(student)
- scienceAll.append(student.science)
- mathsAll.append(student.maths)
- englishAll.append(student.english)
- namez.append(student.name)
- mathsAllSorted = mathsAll[:]
- scienceAllSorted = scienceAll[:]
- englishAllSorted = englishAll[:]
- subBool = True
- while subBool == True:
- #Put this here if yo uwant to display the amount of classes a little better: classesInit = []
- whatClass = input("What class would you like to add a new student to:"+ str(classes.keys()))
- if whatClass in classes:
- classes[whatClass].append(name)
- print("The students in", whatClass, "is")
- for i in range(len(classes[whatClass])):
- print(classes[whatClass][i])
- subBool = False
- else:
- print("Sorry there is no class called" + whatClass)
- #elif statements
- elif menu == 2:
- addNewClass()
- elif menu == 3:
- printAllStudents()
- elif menu == 4:
- lowestToHighest()
- else:
- print("Please select either 1,2,3,4 or 5")
- mainFunct()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement