Python program, user friendly query
Question: I saw your bit explaining how to import these things and generate a random
number using them but can you solve this problem. This is (the starting stages
of) my program:

    
    
    import random
    from operator import add, sub, mul
    for x in range(10):
        ops = (add, sub, mul)
        op = random.choice(ops)
        num1, num2 = random.randint(1,10), random.randint(1,10)
        int(input("What is %s %s %s?\n" % (num1, op, num2)))
        ans = op(num1, num2)
    

However when I execute this code this is printed: What is 8 1? and I was
wondering how I would efficiently print this in a user friendly way such as:
"What is 8 add 1?"

Thankyou if you solve this!


Answer: Maybe use a dictionary instead of a tuple.

    
    
    import random
    from operator import add, sub, mul
    for x in range(10):
        ops = {'+': add, '-': sub, '*': mul}
        op = random.choice(ops.keys())
        num1, num2 = random.randint(1,10), random.randint(1,10)
        int(input("What is %s %s %s?\n" % (num1, op, num2)))
        ans = ops[op](num1, num2)
    

