From f5bae51ee3c89066194a2d97967ecbf6f0f9057a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Wed, 24 Oct 2018 16:53:54 +0200 Subject: [PATCH] Added Exercise 2 --- ex_01_02.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ex_01_02.py diff --git a/ex_01_02.py b/ex_01_02.py new file mode 100644 index 0000000..e7aa68a --- /dev/null +++ b/ex_01_02.py @@ -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")