Skip to content

Commit 08705a4

Browse files
committed
Create Quadratic equation.py
Calculates the roots of a quadratic equation
1 parent e5cad59 commit 08705a4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: Python/Quadratic equation.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
a=int(input('input a='))
2+
b=int(input('input b='))
3+
c=int(input('input c='))
4+
5+
D=(b*b)-(4*a*c)
6+
if D<0:
7+
print('no roots')
8+
elif D==0:
9+
x1 = (-b + (D**0.5))/(2*a)
10+
print('x1=',x1)
11+
else:
12+
x1 = (-b + (D**0.5))/(2*a)
13+
x2 = (-b - (D**0.5))/(2*a)
14+
print('x1=',x1)
15+
print('x2=',x2)
16+
17+
input()

0 commit comments

Comments
 (0)