0

I'm trying to create a quick program that'll do synthetic division for polynomials to the 4th degree, but when I try and execute my code, it'll tell me R*A: Can't assign to operator. I assume that means it can't do the operation of multiplication, but why? I have limited experience in programming, just one year in 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')

2 Answers2

1

I assume you're not trying to re-assign an operator but just doing multiplication.

In python, like many other languages including Java, assignment is done like this:

temp = R*A
qwr
  • 9,525
  • 5
  • 58
  • 102
  • @OberstRyan Python 3 does not automatically change types. Use `int(input(...))` to convert to an integer. – qwr Oct 12 '14 at 02:18
0

Temp = R * A

Your inputs will be str. You need to tell python it will be an int. int (input("...."))