Skip to content

Instantly share code, notes, and snippets.

@srakrn
Created July 28, 2016 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srakrn/00892d26f7b14491af117da1be859f37 to your computer and use it in GitHub Desktop.
Save srakrn/00892d26f7b14491af117da1be859f37 to your computer and use it in GitHub Desktop.
204111 Boost Camp Grader
#############################################
#NAME: Sirakorn Lamyai
#ID: 5910500023
#PROGRAM: myGrader.py
#DATE: 28 Jul 2016
#############################################
import sys
def grade(score):
a = 0;
score = float(score)
if(score>=85):
a = 4
elif(score>=75):
a = 3
elif(score>=65):
a = 2
else:
a = 1
return a
def sumArray(data):
sum = 0
for i in data:
sum += i
return sum
def stdDev(data):
mean = sumArray(data)/len(data)
devScore = 0.0
for i in data:
devScore += (i-mean)**2
return ((devScore/len(data))**0.5)
f = open(sys.argv[1])
lists = f.readlines()
scoreList = []
gradeList = []
for list in lists:
name,score = list.split()
scoreList.append(float(score))
grrrade = grade(score)
gradeList.append(grrrade)
print("%s\t%s\t%s")%(name,score,grrrade)
print(" Mean: %.3f")%(sumArray(scoreList)/len(scoreList))
print(" Standard Deviation: %.3f")%(stdDev(scoreList))
print("===========================")
print(" Grade Point Average: %3.2f")%(sumArray(gradeList)/len(gradeList))
print("===========================")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment