import math
def quadratic():
a = float(input('please input a:'))
b = float(input('please input b:'))
c = float(input('please input c:'))
sol_judge = b**2-4*a*c
if sol_judge >= 0:
x1 = (-b + math.sqrt(sol_judge))/2*a
x2 = (-b - math.sqrt(sol_judge))/2*a
return x1, x2
else:
print('No real solution')
x1, x2 = quadratic()
print('solutions:{},{}'.format(x1,x2))
Sign in to make a reply
潜伏之鳄(steam名Orz)
import math
def quadratic():
a = float(input('please input a:'))
b = float(input('please input b:'))
c = float(input('please input c:'))
sol_judge = b**2-4*a*c
if sol_judge >= 0:
x1 = (-b + math.sqrt(sol_judge))/2*a
x2 = (-b - math.sqrt(sol_judge))/2*a
return x1, x2
else:
print('No real solution')
x1, x2 = quadratic()
print('solutions:{},{}'.format(x1,x2))