Write quadratic_roots(a, b, c) that returns the real solutions of a*x**2 + b*x + c = 0 as a list sorted from smallest to largest, each rounded to 2 decimal places. Return [] if there are no real roots and a one-element list if the two roots are exactly equal. Two different roots always give two elements, even when both round to the same value.
Examples
Input: a = 1, b = -3, c = 2
Output: [1.0, 2.0]
Input: a = 1, b = 2, c = 1
Output: [-1.0]
Input: a = 1, b = 0, c = 1
Output: []
Input: a = 1000, b = -1, c = 0
Output: [0.0, 0.0]
Explanation: the roots 0 and 0.001 are different; both round to 0.0.
Constraints
a != 0; all coefficients are ints or floats with absolute value at most1000
Goals
- Branch on the sign of the discriminant
- Return a list whose length depends on the input
- Round and sort floating-point results