Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as pt
- class Codigo:
- def __init__(self, codigo = "", notasC = []):
- self.codigo = codigo
- self.notasC = notasC
- def getAverage(self):
- s = 0.0
- for x in self.notasC:
- s += x;
- return (s / len(self.notasC))
- def printGrades(self):
- print("-{}: {} --> Average: {:.2f}".format(self.codigo, self.notasC, self.getAverage()))
- def getGroup(self):
- f = self.codigo[0];
- s = self.codigo[1];
- t = self.codigo[2];
- frth = 'z';
- if len(self.codigo) >= 4:
- frth = self.codigo[3];
- if f == 'B':
- return "Biologia";
- if f == 'F':
- return "Fisica";
- if f == 'Q':
- return "Quimica";
- if f == 'M':
- return "Matematica";
- if f == 'C':
- return "Compl. de Matematica";
- if f == 'G':
- return "Geografia";
- if f == 'I':
- return "SAT/TOEFL";
- if f == 'E':
- return "Artes";
- if f == 'L':
- return "Laboratorio";
- if f == 'H':
- if t == '3':
- return "Sociologia";
- if t == '4':
- return "Atualidades";
- return "Historia";
- if f == 'P':
- if s == 'G':
- return "Prova Geral";
- if s == 'R':
- return "Prova de Redacao";
- if t == '5':
- return "Filosofia";
- return "Portugues";
- if f == 'T':
- if frth == 'z':
- return "Temas Diversos";
- if t == '4':
- if frth == '0':
- return "AP Literature";
- if frth == '1':
- return "AP Human Geography";
- if frth == '2':
- return "AP Psychology";
- if frth == '3':
- return "AP CS Principles";
- if frth == '4':
- return "AP French";
- if frth == '0':
- return "AP Language";
- if frth == '1':
- return "AP Calculus";
- if frth == '2':
- return "AP Chemistry";
- if frth == '3':
- return "AP Biology";
- if frth == '4':
- return "AP Statistics";
- if frth == '5':
- return "AP Physics";
- if frth == '6':
- return "AP World History";
- if frth == '7':
- return "AP CS A";
- if frth == '8':
- return "AP Latin";
- if frth == '9':
- return "AP Microeconomics";
- if f == 'V':
- return "Verificacao Final";
- return self.codigo
- def getSum(self):
- s = 0.0
- for x in self.notasC:
- s += x
- return s
- def getAmount(self):
- return len(self.notasC)
- def insertGrade(self, s):
- self.notasC.append(s)
- def __lt__ (self, other):
- return (self.getAverage() < other.getAverage())
- class Materia:
- def __init__(self, nome = "", sum = 0.0, qtd = 0):
- self.nome = nome
- self.sum = sum
- self.qtd = qtd
- def insertGrades(self, a, b):
- self.sum += a
- self.qtd += b
- def getSum(self):
- return self.sum
- def getAmount(self):
- return self.qtd
- def getTotalAverage(self):
- return (self.sum / self.qtd)
- def printAverage(self):
- print("-{}: -> {:.2f}".format(self.nome, self.getTotalAverage()))
- def getGp(self):
- return self.nome
- def setGroup(self, s):
- self.nome = s
- def __lt__ (self, other):
- return (self.getTotalAverage() < other.getTotalAverage())
- f = open("input.txt", "r")
- lines = f.readlines()
- notas = []
- codigos = []
- areas = []
- for materia in lines:
- aux = materia.split()
- # print(aux)
- curname = ""
- curgrade = []
- for s in aux:
- # print(s)
- if s[0].isalpha() and s[-1].isdigit():
- curname = s
- elif s[0].isdigit() and s[-1].isdigit() and len(curname) > 0 and not curname.startswith("AR"):
- curgrade.append((float(s)))
- notas.append(float(s))
- if 0 < len(curname) <= 4 and not curname.startswith('AR'):
- codigos.append(Codigo(curname, curgrade))
- for c in codigos:
- achou = False
- for m in areas:
- if c.getGroup() == m.getGp():
- m.insertGrades(c.getSum(), c.getAmount())
- achou = True
- break
- if achou == True:
- continue
- aux = Materia()
- aux.setGroup(c.getGroup())
- aux.insertGrades(c.getSum(), c.getAmount())
- areas.append(aux)
- GPA = 0.0
- for x in notas:
- GPA += x
- n = len(notas)
- print("GRADE REPORT: \n")
- print("Your GPA is: {:.2f} ({} grades)\n".format(GPA / n, n))
- codigos.sort()
- notas.sort()
- areas.sort()
- print("STATISTICS:")
- print("-MIN: {:.2f}".format(notas[0]))
- print("-Q1: {:.2f}".format(notas[int(n / 4)]))
- print("-Q2 (MEDIAN): {:.2f}".format(notas[int(n / 2)]))
- print("-Q3: {:.2f}".format(notas[n - 1 - int(n / 4)]))
- print("-MAX: {:.2f}".format(notas[n-1]))
- print("-RANGE: {:.2f}".format(notas[n - 1] - notas[0]))
- print("-IQR: {:.2f}".format(notas[n - 1 - int(n / 4)] - notas[int(n / 4)]))
- print("\n")
- print("PER SUBJECT (SORTED BY AVERAGE GRADE): ")
- for c in codigos:
- c.printGrades()
- print("\nAVERAGE PER AREA (SORTED BY AVERAGE GRADE):")
- for m in areas:
- m.printAverage()
- print("\n\nDELTAS TABLE:\n")
- for nextGrade in np.arange(0.0, 10.5, 0.5):
- newGPA = (GPA + nextGrade)/(n+1)
- print("{:.2f} --> {:.2f} and delta {:.2f}".format(nextGrade, newGPA ,newGPA - (GPA / n)))
- pt.hist(notas)
- pt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement