Skip to content

Instantly share code, notes, and snippets.

@knkillname
Last active August 29, 2015 14:03
Show Gist options
  • Save knkillname/8cb043f754a56e109ed7 to your computer and use it in GitHub Desktop.
Save knkillname/8cb043f754a56e109ed7 to your computer and use it in GitHub Desktop.
##Calculadora humana. Por knkillname.
##¡Diviértete!
from random import choice, randint
L = ['+', '-', '×', '/']
while True:
op = choice(L)
if op == '+':
res = randint(1, 99)
a = randint(0, res)
b = res - a
elif op == '-':
res = randint(1, 99)
a = randint(res, 99)
b = a - res;
elif op == '/':
b = randint(1, 9)
res = randint(1, 99)//b
a = b * res
else:
a = randint(0, 9)
if a != 0:
b = randint(0,99)//a
else:
b = randint(0,99)
res = a * b
prompt = '{} {} {} = '.format(a, op, b)
s = int(input(prompt))
while s != res:
print('Incorrecto')
if (res < s):
print('El valor correcto es menor')
else:
print('El valor correcto es mayor')
s = int(input(prompt))
print('Correcto')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment