Exercise 2

Write a function to compute the roots of a mathematical equation of the form \begin{align} ax^{2} + bx + c = 0. \end{align} Your function should be sensitive enough to adapt to situations in which a user might accidentally set $a=0$, or $b=0$, or even $a=b=0$. For example, if $a=0, b\neq 0$, your function should print a warning and compute the roots of the resulting linear function. It is up to you on how to handle the function header: feel free to use default keyword arguments, variable positional arguments, variable keyword arguments, or something else as you see fit. Try to make it user friendly.

Your function should return a tuple containing the roots of the provided equation.

Hint: Quadratic equations can have complex roots of the form $r = a + ib$ where $i=\sqrt{-1}$ (Python uses the notation $j=\sqrt{-1}$). To deal with complex roots, you should import the cmath library and use cmath.sqrt when computing square roots. cmath will return a complex number for you. You could handle complex roots yourself if you want, but you might as well use available libraries to save some work.