-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathP6.py
More file actions
22 lines (19 loc) · 942 Bytes
/
P6.py
File metadata and controls
22 lines (19 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import cmath
a = int(input("Enter the co-efficient of x^2 : "))
b = int(input("Enter the co-efficient of x : "))
c = int(input("Enter the constant : "))
d = (b*b)-(4*a*c)
r1 = (-b-cmath.sqrt(d))/(2*a)
r2 = (-b+cmath.sqrt(d))/(2*a)
print("The roots are "+str(r1)+" and "+str(r2))
''' Output
Enter the co-efficient of x^2 : 1
Enter the co-efficient of x : 4
Enter the constant : 4
The roots are (-2+0j) and (-2+0j)
OR
Enter the co-efficient of x^2 : 3
Enter the co-efficient of x : 4
Enter the constant : 5
The roots are (-0.6666666666666666-1.1055415967851332j) and (-0.6666666666666666+1.1055415967851332j)
'''