1. 程式人生 > >python 求出ax*x + bx + c = 0的兩個解

python 求出ax*x + bx + c = 0的兩個解

import math
def quadratic(a,b,c):
    num = (b*b/(4*a*a))-(c/a);
    num2=math.sqrt(num);
    num3= b/(2*a);
    res = num2-num3;
    res2 = -num2-num3;
    return res,res2;
res =quadratic(2.0,3.0,1.0);
print(res)