Question: def quadratic _ formula ( a , b , c ) : # Calculate the discriminant delta = b * * 2 - 4 *

def quadratic_formula(a, b, c):
# Calculate the discriminant
delta = b**2-4*a*c
# Check if the discriminant is non-negative
if delta >=0:
# Calculate the two solutions using the quadratic formula
x1=(-b +(delta)**0.5)/(2*a)
x2=(-b -(delta)**0.5)/(2*a)
return x1, x2
else:
# If discriminant is negative, return None
return None
# Read input values for a, b, and c
a, b, c = map(float, input().split())
# Call quadratic_formula() function
solutions = quadratic_formula(a, b, c)
# Print the solutions
if solutions is not None:
x1, x2= solutions
print(f"Solutions to {a}x^2+{b}x +{c}=0")
print(f"x1={x1:.2f}")
print(f"x2={x2:.2f}")
else:
print("No real solutions (discriminant is negative)")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!