jeudi 25 janvier 2018

Making a string to a part of the code Python

I want to programm a random genrator for mathtasks. I am at this point:

    first = random.randint(1,100)
    second = random.randint(1,100)
    third = random.randint(1,100)
    R1 = random.choice("+-/*")
    R2 = random.choice("+-/*")
    R3 = random.choice("+-/*")

    x= first + R1 + second + R2 + third + R3

But I know that this wont work, because the +-/* are sawn as a string, not as math actions. Any ideas how to solve this?




Aucun commentaire:

Enregistrer un commentaire