Skip to content

Instantly share code, notes, and snippets.

@NovaAndrom3da
Created May 19, 2022 14:48
Show Gist options
  • Save NovaAndrom3da/b6f3a3c1df880e7ba63368c9e357c561 to your computer and use it in GitHub Desktop.
Save NovaAndrom3da/b6f3a3c1df880e7ba63368c9e357c561 to your computer and use it in GitHub Desktop.
import sys
cat = {}
mp1 = {}
mp2 = {}
def page0():
while True:
c = input(f'\
[add] Add a category\n\
[continue] Continue to the next portion\n\
\n\
{", ".join(cat.keys())}\n> \
')
if c == 'add':
cat[input('Name of category?\n> ')] = int(input('Category weight?\n> '))
elif c == 'continue':
page1()
def page1():
print("[== Marking Period 1 (MP1) ==]")
for g in cat.keys():
mp1[g] = [int(input(f'Maximum points for {g}?\n> ')),
int(input(f'Recieved points for {g}?\n> '))]
print("[== Marking Period 2 (MP2) ==]")
for g in cat.keys():
mp2[g] = [int(input(f'Maximum points {g}?\n> ')),
int(input(f'Recieved points for {g}?\n> '))]
page2()
def page2():
g_out = 0
for g in cat.keys():
g_out += (((mp1[g][1]+mp2[g][1])/(mp1[g][0]+mp2[g][1]))/100)*cat[g]
print(f'Semester average: {g_out}')
sys.exit()
try:
page0()
except ValueError as ve:
print(str(ve))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment