This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

02 - Quadratic equation solver

See the general homework guidelines!

Create a text file quadeq.py. In it, define function get_roots(a, b, c) which

  • accepts the coefficients $a$, $b$, and $c$ of a quadratic equation $ax^2 + bx + c = 0$, and
  • returns a list of its real roots, i.e., the function returns
    • a list with 2 numbers when the equation has 2 real roots,
    • a list with a single number when the equation has a single root only, or
    • an empty list when the equation has no real roots.

Assume that a is always nonzero.


  • 5 points for automatic checks
  • 1 point for manual evaluation (is the code readable, did you use the docstring to comment your function)
courses/be5b33prg/homework/regular/02_quadratic_equation.txt · Last modified: 2020/10/15 11:47 by nemymila