Skip to content

Instantly share code, notes, and snippets.

@brett-stanley
Last active December 4, 2020 19:20
Show Gist options
  • Save brett-stanley/aabe8c7a1429702a4258f72bc13d96d7 to your computer and use it in GitHub Desktop.
Save brett-stanley/aabe8c7a1429702a4258f72bc13d96d7 to your computer and use it in GitHub Desktop.
import numpy as np
#weighting info
hw_weight = 50
hw_total = 400
lab_weight = 10
lab_total = 1200
lecture_midterm_weight = 10
lecture_midterm_total = 100
lab_final_weight = 20
lab_final_total = 200
lecture_final_weight = 10
lecture_final_total = 100
#enter your grades here
hw = np.array([120,130,110,100,160])
lab = np.array([100,100,150,140,50,100,100,100,120,130,100,0])
lecture_midterm = 120
lab_final = 186
lecture_final = 0
#keep top 10 labs
"""
while lab.shape[0] > 10:
lab = np.delete(lab,np.argmin(lab))
"""
#intermediate calcs
labs_points = np.sum(lab)/lab_total*lab_weight
hw_points = np.sum(hw)/hw_total*hw_weight
lecture_midterm_points = lecture_midterm/lecture_midterm_total*lecture_midterm_weight
lab_final_points = lab_final/lab_final_total * lab_final_weight
lecture_final_points = lecture_final/lecture_final_total*lecture_final_weight
#final calc
grade = np.round(np.sum([
labs_points,
hw_points,
lecture_midterm_points,
lab_final_points,
lecture_final_points
]),decimals=2)
letterGrade = 'N/A'
if grade < 59.5:
letterGrade = 'F'
elif grade >= 59.5 and grade < 69.5:
letterGrade = 'D'
elif grade >= 69.5 and grade < 79.5:
letterGrade = 'C'
elif grade >= 79.5 and grade < 89.5:
letterGrade = 'B'
elif grade >= 89.5:
letterGrade = 'A'
else:
letterGrade = 'N/A'
print('Grade: ' + str(grade) + '% ' + letterGrade)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment