Skip to content

Commit 57703a6

Browse files
Create Roots of a Quadratic.py
1 parent 15e4278 commit 57703a6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Roots of a Quadratic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
a=int(input("Enter the Coefficients of x^2 : "))
2+
b=int(input("Enter the Coefficient of x : "))
3+
c=int(input("Enter the constant term : "))
4+
print("Your Inputs produce this quadratic equation : {}x^2 + {}x +{} = 0 ".format(a,b,c))
5+
import cmath #To display Complex roots
6+
d = (b**2) - (4*a*c)
7+
sol1 = (-b-cmath.sqrt(d))/(2*a)
8+
sol2 = (-b+cmath.sqrt(d))/(2*a)
9+
print("Solutions are : ")
10+
print("x = ",sol1,"\nx = ",sol2)

0 commit comments

Comments
 (0)