Skip to content

Commit 320e2a6

Browse files
authored
added program of square root & quadratic root👩‍💻
1 parent a15c1c0 commit 320e2a6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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
14+
sol1 = (-b-cmath.sqrt(d))/(2*a)
15+
sol2 = (-b+cmath.sqrt(d))/(2*a)
16+
17+
print('The solution are {0} and {1}'.format(sol1,sol2))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Python Program to calculate the square root
2+
3+
# Note: change this value for a different result
4+
num = 8
5+
6+
# To take the input from the user
7+
#num = float(input('Enter a number: '))
8+
9+
num_sqrt = num ** 0.5
10+
print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))

0 commit comments

Comments
 (0)