First read the input from the command line (hint : use sys.argv
). Also you will need to figure out how to convert strings to python numbers.
Then check if b**2-4*a*c < 0
. If yes, then raise a ValueError
about that there are no real roots.
Else solve for the roots: roots = (b ± sqrt(b**2-4*a*c)) / (2*a)
solved Root of quadratic polynomial with Python