scientific-programming-exer.../ex_01_02.py
2018-10-24 16:53:54 +02:00

21 lines
460 B
Python

#!/usr/bin/python3
import random
from util.io import readvalue
if( __name__ == "__main__"):
random_value = random.randint(1, 6)
print("I just generated a random number between 1 and 6")
guess = -1
while(1):
guess = readvalue("Could you guess it? Try: ", int)
if(not(1 <= guess <= 6)):
print("Your number is not in the interval.")
else:
break
if(guess != random_value):
print("Wrong, it was", random_value, "!")
else:
print("Nice try")