Added Exercise 2

gol
Daniel Knüttel 2018-10-24 16:53:54 +02:00
parent 567a95a2b2
commit f5bae51ee3
1 changed files with 20 additions and 0 deletions

20
ex_01_02.py 100644
View File

@ -0,0 +1,20 @@
#!/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")