Académique Documents
Professionnel Documents
Culture Documents
-Statistics
-Finish last part of part E
'''
STUDENT_SCORE_FILENAME='student_data_prog2.txt'
return name,status,lab1,lab2,lab3,lab4,lab5,lab6,lab7,lab8,lab9,lab10,prog1,
prog2,prog3,mid1,mid2,final,hw,part
return studentData
def sortmenu():
print '''Choose which data to sort:
l for lab average
p for program average
m for midterm average
f for final average
w for weighted total percentage
'''
choice = raw_input("Input now: ")
if choice == 'l':
print "You have selected sorting student data by lab average"
category = 1
elif choice == 'p':
print "You have selected sorting student data by program average"
category = 2
elif choice == 'm':
print "You have selected sorting student data by midterm average"
category = 3
elif choice == 'f':
print "You have selected sorting student data by final average"
category = 4
elif choice == 'w':
print "You have selected sorting student data by total percentage"
category = 5
else:
print "Error! Not valid input!"
return category
def writeFile(fileName,category,name,status,lab1,lab2,lab3,lab4,lab5,lab6,lab7,l
ab8,lab9,lab10,prog1,prog2,prog3,mid1,mid2,final,hw,part):
def spacer():
outfile.write(" ")
dump = [] #This is the actual value being compared in the bubble sort
dumpindex = [] #This is the corresponding line number of that value, will be
returned by bubble sort
if category == 1: #Sorting by lab average
for i in range(60):
dump.append((lab1[i]+lab2[i]+lab3[i]+lab4[i]+lab5[i]+lab6[i]+lab
7[i]+lab8[i]+lab9[i]+lab10[i])/10)
dumpindex.append(i)
elif category == 2: #Sorting by program average
for i in range(60):
dump.append((prog1[i]+prog2[i]+prog3[i])/3)
dumpindex.append(i)
elif category == 3: #Sorting by midterm average
for i in range(60):
dump.append((mid1[i]+mid2[i])/2)
dumpindex.append(i)
elif category == 4: #Sorting by final average
for i in range(60):
dump.append(final[i])
dumpindex.append(i)
elif category == 5: #Sorting by total percentage
for i in range(60):
thisperson=[name[i],status[i],lab1[i],lab2[i],lab3[i],lab4[i],la
b5[i],lab6[i],lab7[i],lab8[i],lab9[i],lab10[i],prog1[i],prog2[i],prog3[i],mid1[i
],mid2[i],final[i],hw[i],part[i],i]
dump.append(WeightedTotalGrade(thisperson))
dumpindex.append(i)
outfile = open(fileName,'w')
neworder = BubbleSort2(dump,dumpindex) #The new order that the lines should
be in
for i in range(60):
outfile.write(name[neworder[i]])
spacer()
outfile.write(str(status[neworder[i]]))
spacer()
outfile.write(str(lab1[neworder[i]]))
spacer()
outfile.write(str(lab2[neworder[i]]))
spacer()
outfile.write(str(lab3[neworder[i]]))
spacer()
outfile.write(str(lab4[neworder[i]]))
spacer()
outfile.write(str(lab5[neworder[i]]))
spacer()
outfile.write(str(lab6[neworder[i]]))
spacer()
outfile.write(str(lab7[neworder[i]]))
spacer()
outfile.write(str(lab8[neworder[i]]))
spacer()
outfile.write(str(lab9[neworder[i]]))
spacer()
outfile.write(str(lab10[neworder[i]]))
spacer()
outfile.write(str(prog1[neworder[i]]))
spacer()
outfile.write(str(prog2[neworder[i]]))
spacer()
outfile.write(str(prog3[neworder[i]]))
spacer()
outfile.write(str(mid1[neworder[i]]))
spacer()
outfile.write(str(mid2[neworder[i]]))
spacer()
outfile.write(str(final[neworder[i]]))
spacer()
outfile.write(str(hw[neworder[i]]))
spacer()
outfile.write(str(part[neworder[i]]))
outfile.write('\n')
outfile.close()
if (ch=='a'):
student_last_name=raw_input("Type the Student's Last Name:")
studentData=get_data_for_student(student_last_name,status,lab1,lab2,lab3
,lab4,lab5,lab6,lab7,lab8,lab9,lab10,prog1,prog2,prog3,mid1,mid2,final,hw,part,n
ame)
print "This student's lab average is %f" % LabAverage(studentData[1:10])
elif (ch=='b'):
student_last_name=raw_input("Type the Student's Last Name:")
studentData=get_data_for_student(student_last_name,status,lab1,lab2,lab3
,lab4,lab5,lab6,lab7,lab8,lab9,lab10,prog1,prog2,prog3,mid1,mid2,final,hw,part,n
ame)
print "This student's program average is %f" % ProgramAverage(studentDat
a[11:13])
elif (ch=='c'):
student_last_name=raw_input("Type the Student's Last Name:")
studentData=get_data_for_student(student_last_name,status,lab1,lab2,lab3
,lab4,lab5,lab6,lab7,lab8,lab9,lab10,prog1,prog2,prog3,mid1,mid2,final,hw,part,n
ame)
print "This student's weighted total percentage is %f" % WeightedTotalGr
ade(studentData)
elif (ch=='d'):
student_last_name=raw_input("Type the Student's Last Name:")
studentData=get_data_for_student(student_last_name,status,lab1,lab2,lab3
,lab4,lab5,lab6,lab7,lab8,lab9,lab10,prog1,prog2,prog3,mid1,mid2,final,hw,part,n
ame)
percentage = WeightedTotalGrade(studentData)
print "This student's letter grade is %s" % Grade(percentage)
elif (ch=='e'):
category = sortmenu() #Thing that is being sorted
fileName = raw_input("Input file name to save to. Be sure to include '.t
xt'")
writeFile(fileName,category,name,status,lab1,lab2,lab3,lab4,lab5,lab6,la
b7,lab8,lab9,lab10,prog1,prog2,prog3,mid1,mid2,final,hw,part)