I started today playing a little bit with python, so I'm really new. I wanted to make a quiz for my little brother, that will generate multiplication functions of random numbers between 0 and 10. Everything went fine, except one thing- when I run the code it always returns false, even when I write a correct input. I think the main problem is in the "if" statment, and I think the problem is that my input is not really equal to the "multiplication", but I dont know how to fix it. I can't understand why the "one" is not equal to the "multiplication", I though the "multiplication" is basically the answer to the multiplication of the two random numbers, and if my input is correct it should be equal and print "true". I would really like so help, I've been breaking my head over it for couple of hours now. Thanks!
random_num1 = random.randrange(0, 10)
random_num2 = random.randrange(0, 10)
print(random_num1, 'X', random_num2, '=', )
def multiplication(random_num1, random_num2):
sumNum = random_num1 * random_num2
return sumNum
one = input()
if(one == multiplication):
print('true')
else:
print('false')
Aucun commentaire:
Enregistrer un commentaire