Skip to content

Commit 68a969d

Browse files
Merge pull request #7 from sidtiwari2712/main
python
2 parents 9c3d5ca + 1b3f7d2 commit 68a969d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

solve quadratic

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))

swap in python

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Python program to swap two variables
2+
3+
x = 5
4+
y = 10
5+
6+
# To take inputs from the user
7+
#x = input('Enter value of x: ')
8+
#y = input('Enter value of y: ')
9+
10+
# create a temporary variable and swap the values
11+
temp = x
12+
x = y
13+
y = temp
14+
15+
print('The value of x after swapping: {}'.format(x))
16+
print('The value of y after swapping: {}'.format(y))

0 commit comments

Comments
 (0)