Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
yield solution in Clear category for Quadratic Equation Roots by kdim
from collections.abc import Iterable
from typing import Union
def quadratic_roots(a: int, b: int, c: int) -> Iterable[Union[int | float] | str]:
D = b ** 2 - 4 * a * c
if D >= 0:
yield (-b + D ** 0.5) / 2 / a
yield (-b - D ** 0.5) / 2 / a
else:
yield "No real roots"
Jan. 5, 2024