【发布时间】:2014-12-06 21:25:51
【问题描述】:
我正在尝试创建一个快速程序,它将对多项式进行 4 次合成除法,但是当我尝试执行我的代码时,它会告诉我 R*A:无法分配给运算符。 我认为这意味着它不能进行乘法运算,但为什么呢?我的编程经验有限,Java CompSci 才一年
print("This program assumes that the polynomial is to the 4th degree")
A = input('Input the first coefficient: ')
B = input('Input the second coefficient: ')
C = input('Input the third coefficient: ')
D = input('Input the fourth coefficient: ')
E = input('Input constant: ')
R = input('Input the divisor: ')
temp = 0
R*A = temp
#B + temp = temp
#R * temp = temp
#C + temp = temp
#R * temp = temp
#D + temp = temp
#R * temp = temp
#E + temp = temp
if temp == 0:
print("It works!")
else:
print("dang")
input('This is a shitty workaround for pause')
【问题讨论】:
-
不要尝试分配给乘法,而是分配给
temp。temp = R * A。换句话说,听起来好像你的语法顺序搞混了。 -
else:之后的缩进也是双倍的!