Skip to content

Commit 48a37ba

Browse files
Merge pull request seeditsolution#316 from Saurabhswaraj920/patch-1
solveQuadraticEq
2 parents 18264c1 + 0adb443 commit 48a37ba

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

solveQuadraticEq

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Solve the quadratic equation ax**2 + bx + c = 0
2+
3+
# import complex math module
4+
import cmath
5+
6+
a = 1
7+
b = 5
8+
c = 6
9+
10+
# calculate the discriminant
11+
d = (b**2) - (4*a*c)
12+
13+
# find two solutions irrespective of the nature of roots
14+
sol1 = (-b-cmath.sqrt(d))/(2*a)
15+
sol2 = (-b+cmath.sqrt(d))/(2*a)
16+
17+
# printing the solution of quatratic equation
18+
print('The solution are {0} and {1}'.format(sol1,sol2))

0 commit comments

Comments
 (0)