小编Rič*_*iņš的帖子

python数学的问题

我正在创建一个程序,它将教我的小弟弟数学.但是例如,当程序说2 + 2时,我输入4就说"不正确!".我究竟做错了什么?

import random
import math

def addition():
    num1 = random.randint(1, 100)
    num2 = random.randint(1, 100)
    result = num1 + num2
    guess = input(str(num1) + " + " + str(num2) + " = ")#this is the line with problem
    if guess == result:
        print("Correct!")
    if guess != result:
        print("Incorrect!")
addition()
Run Code Online (Sandbox Code Playgroud)

python math python-3.x

-3
推荐指数
1
解决办法
75
查看次数

标签 统计

math ×1

python ×1

python-3.x ×1