Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
# quadratic.py
# A program that computes the real roots of a quadratic equation.
# Illustrates use of the math library.
# Note: This program crashes if the equation has no real roots.
import cmath # Makes the math library available.
print("This program finds the real solutions to a quadratic")
a=-2
b=5
c=1
discRoot = cmath.sqrt( a * c)
root1 = (-b + discRoot)
root2 = (-b - discRoot)
print("The solutions are:", root1, root2 )
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more