我正在嘗試創建一個快速程序,它將對多項式進行四次合成除法,但是當我嘗試執行代碼時,它會告訴我R * A:無法分配給運算符。 我認爲這意味着它不能做乘法運算,但爲什麼?我在編程方面的經驗有限,只用了一年Java CompSciPython 3.4:如何爲運營商分配變量?
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'。換句話說,聽起來好像你的語法順序混淆了。 – 2014-10-12 01:25:57
縮進在'else:'之後加倍! – W1ll1amvl 2014-10-12 01:28:02