Created
February 17, 2020 17:34
-
-
Save tomiolah/042655b98bd21b6b2507cf5f50600d7b to your computer and use it in GitHub Desktop.
University Media Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python3 | |
class Subject: | |
def __init__(self, grade: int, credit: int): | |
self.g = grade | |
self.c = credit | |
#################################### | |
# CHANGE HERE # | |
#################################### | |
grades = [ | |
Subject(grade=9, credit=5), | |
Subject(grade=8, credit=4), | |
Subject(grade=10, credit=6), | |
Subject(grade=10, credit=5), | |
Subject(grade=9, credit=4), | |
Subject(grade=9, credit=2), | |
Subject(grade=10, credit=4), | |
] | |
#################################### | |
# CHANGE HERE # | |
#################################### | |
ct = sum([ | |
s.c for s | |
in grades | |
], 0) | |
final = sum([ | |
(s.c * s.g) / ct | |
for s in grades | |
], 0) | |
class c: | |
reset='\033[0m' | |
bold='\033[01m' | |
disable='\033[02m' | |
underline='\033[04m' | |
reverse='\033[07m' | |
strikethrough='\033[09m' | |
invisible='\033[08m' | |
class fg: | |
black='\033[30m' | |
red='\033[31m' | |
green='\033[32m' | |
orange='\033[33m' | |
blue='\033[34m' | |
purple='\033[35m' | |
cyan='\033[36m' | |
lightgrey='\033[37m' | |
darkgrey='\033[90m' | |
lightred='\033[91m' | |
lightgreen='\033[92m' | |
yellow='\033[93m' | |
lightblue='\033[94m' | |
pink='\033[95m' | |
lightcyan='\033[96m' | |
class bg: | |
black='\033[40m' | |
red='\033[41m' | |
green='\033[42m' | |
orange='\033[43m' | |
blue='\033[44m' | |
purple='\033[45m' | |
cyan='\033[46m' | |
lightgrey='\033[47m' | |
print( | |
f'\n{c.fg.lightgreen}' + | |
f'Your final score is{c.reset} ' + | |
f'{c.fg.yellow}{c.bold}{c.underline}' + | |
f'{final}{c.reset} {c.fg.lightred}(' + | |
f'~ {c.bold}{round(final)}{c.reset}' + | |
f'{c.fg.lightred}){c.reset}' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment