import math
def quadratic(a, b, c):
m = b*2 - 4 a c
x1 = (-b + math.sqrt(m)) / (2 a)
x2 = (-b - math.sqrt(m)) / (2 * a)
if a < 0:
return 'is not a quadratic equation of one unknown'
elif m < 0:
return 'no value'
elif m > 0:
return x1, x2
print('welcome to caculate the quadratic equation of one unknown')
a = float(input('please enter a = '))
b = float(input('please enter b = '))
c = float(input('please enter c = '))
r = quadratic(a, b, c)
print('x1 = ', r[0])
print('x2 = ', r[1])
Zick-Bill
import math def quadratic(a, b, c): m = b*2 - 4 a c x1 = (-b + math.sqrt(m)) / (2 a) x2 = (-b - math.sqrt(m)) / (2 * a) if a < 0: return 'is not a quadratic equation of one unknown' elif m < 0: return 'no value' elif m > 0: return x1, x2 print('welcome to caculate the quadratic equation of one unknown') a = float(input('please enter a = ')) b = float(input('please enter b = ')) c = float(input('please enter c = ')) r = quadratic(a, b, c) print('x1 = ', r[0]) print('x2 = ', r[1])