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!
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
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
Great Thanks! That helps a lot!
Join our real-time social learning platform and learn together with your friends!