0

我正在尝试创建一个快速程序,它将对多项式进行四次合成除法,但是当我尝试执行我的代码时,它会告诉我 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')
4

2 回答 2

1

我假设您不是在尝试重新分配运算符,而只是在进行乘法运算。

在 python 中,与包括 Java 在内的许多其他语言一样,赋值是这样完成的:

temp = R*A
于 2014-10-12T01:28:24.273 回答
0

温度 = R * A

您的输入将是 str。你需要告诉python它将是一个int。整数(输入(“....”))

于 2014-10-12T02:14:53.063 回答