I have a simple maths task I'm having problems executing, involving the random import. The idea is that there is a quiz of 10 randomly generated questions. I've got the numbers ranging from (0,12) using the random.randint function, that works fine. Its the next bit of choosing a random operator I'm having problems with ['+', '-', '*', '/'].
I have my more sophisticated coding back at school, but this is my practise one that all I need is the ability to randomly create a question and ask it, whilst also being able to answer it itself to determine if the answer given is correct. Here's my code:
import random
ops = ['+', '-', '*', '/']
num1 = random.randint(0,12)
num2 = random.randint(0,10)
operation = random.choice(ops)
print(num1)
print(num2)
print(operation)
maths = num1, operation, num2
print(maths)
As of right now though, my output is a little messed up. For example:
3
6
*
(3, '*', 6)
Clearly it can't determine the answer from (3, '*', 6). I'll be turning this operation into a subroutine in my other program, but it needs to work first!
And forgive me if its not very well done, this was a quick recreation of the task I left at school, and I'm also fairly new at this with limited knowledge. Thanks in advance!