Search code examples
pythondivisionsynthetic

Python 3.4: How do I assign variables to operators?


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')

Solution

  • 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