20 lines
291 B
Python
20 lines
291 B
Python
from math import sqrt
|
|
|
|
|
|
def find_discr(a, b, c):
|
|
return b**2 - 4 * a * c
|
|
|
|
|
|
def solve_sq(a, b, c):
|
|
d = find_discr(a, b, c)
|
|
if d < 0:
|
|
return
|
|
if d == 0:
|
|
return -b / (2 * a)
|
|
return tuple(
|
|
(-b + s * sqrt(d)) / (2 * a)
|
|
for s in [-1, 1]
|
|
)
|
|
|
|
|