# quadratic_with_IF.py
#
# A program that computes the real roots of a quadratic equation.
# Uses a simple if to avoid program crash
#
# Program has problems: (1) no information is given to user if
# there are no real roots, (2) would be helpful to recognize double roots
import math
def main():
print "This program finds the real solutions to a quadratic\n"
a, b, c = input("Please enter the coefficients (a, b, c): ")
discrim = b * b - 4 * a * c
if discrim >= 0:
discRoot = math.sqrt(discrim)
root1 = (-b + discRoot) / (2 * a)
root2 = (-b - discRoot) / (2 * a)
print "\nThe solutions are:", root1, root2
main()