0

code to solve quadratic equation in python

6th Jul 2016, 10:54 AM
rishu
3 odpowiedzi
+ 4
from math import sqrt a,b,c=input(),input(),input() d=b*b-4*a*c print("roots are",(-b+sqrt(d))/(2*a),(-b-sqrt(d))/(2*a)
6th Jul 2016, 5:47 PM
Vansh Batra
Vansh Batra - avatar
+ 3
yes u may check and put in a try block also
7th Jul 2016, 7:35 AM
Vansh Batra
Vansh Batra - avatar
+ 1
I personally prefer using d to check if there is a real answer, but yeah, @Vansh has the right of it
7th Jul 2016, 6:40 AM
Yarden Akin
Yarden Akin - avatar