Ask coding questions

← Back to all posts
Python Syntax error
DavidSafro (19)

Why does this not work? It gives me an error that I do not understand.

Answered by IMayBeMe (346) [earned 5 cycles]
View Answer
IMayBeMe (346)

I'm pretty sure this happens if it's trying to calculate something that is not mathematically possible.

DavidSafro (19)

@IMayBeMe yes but what is impossible here? its just a quadratic formula

IMayBeMe (346)

@DavidSafro yeah I’m not really sure about that as it looks ok from a math standpoint

DavidSafro (19)

@IMayBeMe k thx u were right it gave error because you cannot have a square root of a number less than zero which was the final sum in most cases

IMayBeMe (346)

@DavidSafro Oh ok so I'm guessing that would return no solution?

LukeWright (114)

if you are asking for a coeffiecient, the input should be a string, not an integer. remove the int( from in front of the inputs like so:

a = input("first coefficient: ")
b = input("second coefficient: ")
c = input("Second coefficient: ")
DavidSafro (19)

@LukeWright THat was what I did first. When I do that, it takes the variables as a str and when I try to run the algorithim, it says error cuz u cant do math with int+var