Created
December 4, 2021 21:18
-
-
Save amineds/5a7efcf189c4de1b88d983b2cc03465b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
import random | |
from termcolor import colored, cprint | |
sequence = 15 #number of operations to solve | |
positive = 0 #good results | |
for i in range(0,sequence): | |
x= random.randint(2,9); y= random.randint(2,9) | |
print('\n') | |
print(f'==> {x} x {y} = ') | |
for line in sys.stdin: | |
try: | |
if int(line.rstrip()) == x*y : | |
print(colored('GOOD RESULT, WELL DONE !','green')) | |
positive=positive + 1 | |
else : | |
print(colored(f'SORRY, BAD RESULT ! {x} * {y} = {x*y} !','red')) | |
break | |
except ValueError: | |
print('PLEASE INTER A VALID INTEGER') | |
print("\n") | |
print("YOU'RE DONE !") | |
print("\n") | |
cprint(f"YOU SCORED {positive} / {sequence}",'magenta',attrs=['bold']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment