- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoefficient.py
More file actions
Latest commit
16 lines (12 loc) · 437 Bytes
/
Copy pathcoefficient.py
File metadata and controls
16 lines (12 loc) · 437 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
importcmath
# Get user input for coefficients
a=float(input("Enter the coefficient a: "))
b=float(input("Enter the coefficient b: "))
c=float(input("Enter the coefficient c: "))
# Calculate the discriminant
discriminant=cmath.sqrt(b**2-4*a*c)
# Calculate the solutions
solution1= (-b+discriminant) / (2*a)
solution2= (-b-discriminant) / (2*a)
# Display the solutions
print(f"Solutions: \n{solution1}\n{solution2}")