Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions