From 236ff0c1247edb016ad7c3a2fdc90dc2326d9350 Mon Sep 17 00:00:00 2001 From: freena koikoi Date: Thu, 20 Jul 2023 11:02:09 +0000 Subject: [PATCH] Upload files to '' --- chapter2.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 chapter2.py diff --git a/chapter2.py b/chapter2.py new file mode 100644 index 0000000..11416e8 --- /dev/null +++ b/chapter2.py @@ -0,0 +1,39 @@ +from random import randint +num1 = randint(1,10) +num2 = randint(1,10) + +#challenge 1 +solution = num1 * num2 +print("What is " + str(num1) + " times " + str(num2) + "? ", solution) + +#challenge 2 +solution = num1 + num2 +print("What is " + str(num1) + " plus " + str(num2) + "? ", solution) + +#challenge 3 +question = f"What is {num1} times {num2}? " +answer = int(input(question)) + +if num1 * num2 == answer: + print("correct") + +else: + print("incorrect") + +#challenge 4 +for number in range(1,12): + if number % 2 <= 0: + print("result") + +#challenge 5 +question = f"What is {num1} times {num2}? " +answer = int(input(question)) + +question = f"What is {num1} times {num2}? " +answer = int(input(question)) + +if num1 * num2 == answer: + print("you got it right") + +else: + print("wrong, the correct answer is:", num1 * num2) \ No newline at end of file