Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

In the first lecture recitation, it asks for Positive root of the following equation: 34*x^2 + 68*x - 510 Recall: a*x^2 + b*x + c x1 = ( - b + sqrt ( b*b - 4*a*c ) ) / ( 2*a) Is there a simpler way to calculate this using python than going line by line calculating each separate equation, such as math.sqrt((68*68)-(4*34*-510)) 272.0 272.0/68 4 -68+4 -64 I am not even sure I got the right answer, so let me know where I am messing up here. Thanks!

OpenStudy (anonymous):

you can type all those calculations in one step (-b+math.sqrt(b*b-4*a*c))/(2*a) but it should be plus minus square root... and then u should check if it's positive or negative

OpenStudy (anonymous):

ah and you also should check that b*b-4*a*c wouldn't be negative because it will give error if you try take square from it

OpenStudy (anonymous):

Great Thanks! That helps a lot!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!