【发布时间】:2023-04-02 00:25:01
【问题描述】:
有没有人碰巧看到导致我拉出语法错误的一个或多个错误?
#dividing integers
first = int (input('What is your first integer '))
second = int (input('What is your second integer '))
quotient = int (input('State the quotient of', str(first) , 'divided by', str(second))
print('you said the quotient is ', quotient)
if quotient== first / second:
print('you are correct')
else:
print('you are incorrect')
print ( 'the quotient is ', first / second)
【问题讨论】:
-
您在
quotient = int(input( ...末尾缺少最后的) -
尝试在您的问题中更具体。错误到底是什么意思?
-
绝对不是
print()语句。 -
first / second将始终导致浮动。你正在检查浮点数的 int 值。除非您将其转换为 int 并检查,否则您将永远无法获得 int 值 -
我尝试了答案中的代码,我输入了
100,然后输入了10,然后是10,程序打印了:you are correct。