Skip to content

Instantly share code, notes, and snippets.

@eebmagic
Created April 17, 2021 17:24
Show Gist options
  • Save eebmagic/53ca8a33fcddf2da0f3b9740f540e4c0 to your computer and use it in GitHub Desktop.
Save eebmagic/53ca8a33fcddf2da0f3b9740f540e4c0 to your computer and use it in GitHub Desktop.
with open('homeworks.txt') as file:
content = file.read().strip()
homeworks = [int(x) for x in content.split('\n')]
with open('tests.txt') as file:
content = file.read().strip()
tests = [int(x) for x in content.split('\n')]
# Fill 100s for remaining grades
fillGrades = False
if fillGrades:
fill = 100
while len(homeworks) != 13:
homeworks.append(fill)
while len(tests) != 5:
tests.append(fill)
avg_hw = round(sum(homeworks)/len(homeworks), 2)
avg_tests = round(sum(tests)/len(tests), 2)
project = 100
grade = round((avg_hw * 0.5) + (avg_tests * 0.4) + (project * 0.1), 2)
print(f'Homeworks: {homeworks}')
print(f'Tests: {tests}')
print(f'\nHomework Avg: {avg_hw}')
print(f' Tests Avg: {avg_tests}')
print(f' Project: {project}')
print(f'\n Grade: {grade}%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment