# -*- coding: utf-8 -*-
import math
def quadratic(a,b,c):
if not isinstance(a,(int,float)):
raise TypeError('first bad perand type')
if not isinstance(b,(int,float)):
raise TypeError('second bad perand type')
if not isinstance(c,(int,float)):
raise TypeError('third bad perand type')
temp=b*b-4*a*c
if temp<0:
return '该方程没有实数解'
elif a==0:
return '该方程不是一元二次方程,是一元一次方程'
elif temp==0:
return '该方程只有一个解,解为:%f'%(-b/(2*a))
else:
return (-b+math.sqrt(temp))/(2*a),(-b-math.sqrt(temp))/(2*a)
逝去的9211