Added Exercise 2
This commit is contained in:
parent
567a95a2b2
commit
f5bae51ee3
20
ex_01_02.py
Normal file
20
ex_01_02.py
Normal 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")
|
Loading…
Reference in New Issue
Block a user