Created
February 17, 2022 03:36
-
-
Save yueyericardo/bc6bba2ae0a0c964be5c9cff291dbe4b to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
total = 10 | |
def info(text): | |
print('\033[32m{}\33[0m'.format(text)) # green | |
def cal(points): | |
eq = points.replace(' ', ' + ') | |
eq = f'{total} - ({eq})' | |
total1 = eval(eq) | |
points = points.split(' ') | |
sub = 0 | |
for p in points: | |
sub += float(p) | |
total2 = total - sub | |
print('Total1: {} = {}'.format(total1, eq)) | |
print('Total2: {}'.format(total2)) | |
while(True): | |
info(f'Grading: Please input points to be subtracted from {total}, seperate them with space') | |
points = input() | |
if len(points) == 0: | |
print("[Process completed]") | |
break | |
if points[-1] == ' ': | |
points = points[:-1] | |
cal(points) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment