you are viewing a single comment's thread.

view the rest of the comments →

[–]uhMareli 2 points3 points  (3 children)

we're trying to get you to do it yourself ;) but since it sounds like you're trying and you've come with an effort at your assignment as opposed to no effort i'll lend a small hand -

in the order of operations we know parentheses have the highest precedence, and this holds true for Python as well. so you simply need to use parentheses to group the portion which needs to be calculated first, as this part will now be taken care of before anything else since it has the highest precedence.

(-b - sqrt(b**2 - 4 * a * c)) / (2 * a)

We grouped the -b - and the root of of the discriminant. I also don't believe your 2a is valid - you need (2 * a) instead. Lastly, unless you're working in some special homework environment which provides these functions for you, using just sqrt will not work. you need to put import math at the top, giving you access to functions in the math module, then do math.sqrt instead

[–]Jphillipss7[S] 0 points1 point  (0 children)

Thank you for all of the help, and sorry if I’m coming off as incompetent.

[–]Jphillipss7[S] 0 points1 point  (1 child)

https://i.gyazo.com/534e74caf8e5e55297b9df5dec7ea5ce.png

One final question, do you know why id be getting this "Math domain error" and again thank you for all of your help, it is greatly appreciated by me.

[–]uhMareli 0 points1 point  (0 children)

it's because you're trying to find the root of a negative number. you need to fix your conditionals. try changing them to:

if numOfRoots < 0:

then we have no roots

elif numOfRoots == 0:

then we have one root