Step 3 – Asking a question

I want to use random numbers to generate a random question.
Something like: "What's 7 times 4".
This is a bit tricky, because we need to add code in two places.
- At the top of your code add: import random
Python needs this to be there to generate random numbers
- Then at the bottom generate the random numbers using number1 = random.randint(1, 12)
This will generate a random integer between 1 and 12.
- Repeat this for another variable called number2
- Then ask the question. Use something like: print("What is", number1, "times", number2)
Watch the commas here!
- Run your program
This should work, but you won't be able to provide an answer yet.
THEORY: random.randint(1, 12) generates a random number between 1 and 12. You can get bigger numbers or reduce the range of numbers if you wan – the 1 times table is a bit easy!.