d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Total Noob Question > Python
Add Reply New Topic New Poll
Member
Posts: 7,459
Joined: Jul 31 2009
Gold: 3,618.00
Sep 12 2017 10:38am
Ok so I am new to programming.. like rly new. I took a class to learn python and I'm already finding this to be a pain xD

Trying to write a code that can calculate the root of a polynomial. So I start with this code, and I get the error TypeError: unsupported operand type(s) for +: 'int' and 'tuple' for the 4th and the 5th line. I just have no idea whats being identified as a tuple.

a,b,c = 2,5,2 #coefficients
r = b**2-4ac
rr = r**0,5 #squareroot of r
x1 = (-b+rr) / (2*a) #first root
x2 = (-b-rr) / (2*a) #second root

print(x1)
print(x2)

And try to dumb down your answers as much as possible, I rly dont know anything about programming as I'm only in week 1 of my class.

Thx a lot!

Member
Posts: 3,028
Joined: Mar 23 2016
Gold: 7,568.50
Sep 12 2017 11:52am
In python and most programming languages, the decimal mark is represented by a dot and not a comma.

What your code currently does is assign to rr the tuple containing (r**0) and (5).
Member
Posts: 7,459
Joined: Jul 31 2009
Gold: 3,618.00
Sep 12 2017 12:11pm
Quote (annexusquam @ 12 Sep 2017 13:52)
In python and most programming languages, the decimal mark is represented by a dot and not a comma.

What your code currently does is assign to rr the tuple containing (r**0) and (5).


Ahhhh I see thx a lot for the quick reply.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll