Your question is Quadratic Formula Function. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Flock Safety camera analytics can produce calibration equations that need to be solved reliably. Implement a function that resolves ax² + bx + c = 0, including degenerate and complex-valued cases.
Write solve_quadratic(a, b, c), where a, b, and c are integers or floating-point numbers. Return a dictionary with a type field and a roots field:
type is one of "quadratic", "linear", "identity", or "none".[real_part, imaginary_part].0.Use a numerically stable approach for two distinct real roots rather than directly evaluating the conventional formula twice.
def solve_quadratic(a, b, c):