Created
October 13, 2016 07:55
-
-
Save albertochiwas/99ba9204dbddd91c5f62a9e12f9d11e1 to your computer and use it in GitHub Desktop.
Juego adivina
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
# Filename: adivina.py, alberto@acm.org, Oct'09 | |
import random | |
def num_azar(m): return random.randint(1,m) | |
def leer(s): return int(input(s)) | |
oculto = num_azar(1000) | |
print "\n* JUEGO: ADIVINA NUMERO 1-1000 *" | |
for i in range(1,20): | |
num = leer("%d) ANOTA NUMERO: " % i) | |
if num == oculto: | |
print "GANASTE.. FELICIDADES!" | |
break | |
elif num < oculto: | |
print "ANOTA UN NUMERO MAYOR QUE %d" % num | |
else: | |
print "ANOTA UN NUMERO menor QUE %d" % num | |
else: | |
print "EL NUMERO ERA %d" % oculto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment