Python實現一元二次方程的定義是:ax2 + bx + c = 0 請編寫一個函數,返回一元二次方程的解。

import math def quadratic_equation(a, b, c): t = math.sqrt(pow(b, 2) - 4 * a * c) if(pow(b, 2) - 4 * a * c) > 0: return (-b + t) / (2 * a), (-b - t) / (2 * a) elif (po
相關文章
相關標籤/搜索