Skip to content

Instantly share code, notes, and snippets.

@DhruvDazer
Created September 5, 2020 14:45
# Calculation of the roots of quadratic equation using the quadratic formula
import math
d= b**2 - 4*a*c
if d<0:
print("As the discriminant in the equation is equal to zero, it doesn't have real roots.")
else:
root1= ((-b) + math.sqrt(d))/(2*a)
root2= ((-b) - math.sqrt(d))/(2*a)
print("The roots of this quadratic equation are: ", root1, " and " , root2, " .")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment