交作业2015.7.5
Topic source我就改变了一下 为什么就不行了呢 一直报错 line24 in<module> line 8 ,in quadratic TypeError a bad operand type
``` 在此插入代码
```# -- coding: utf-8 --
import math
定义求解函数
def quadratic(a,b,c):
if not isinstance(a,(int,float)):
raise TypeError('a bad operand type')
if not isinstance(b,(int,float)):
raise TypeError('b bad operand type')
if not isinstance(c,(int,float)):
raise TypeError('c bad operand type')
x3=bb-4ac
if x3>=0:
x1=(-b+math.sqrt(x3))/(2a)
x2=(-b-math.sqrt(x3))/(2*a)
return x1,x2
else:
return 0
a1=input() b1=input() c1=input() print(quadratic(a1,b1,c1))
- 1
Gussun
注意: 1、isinstance每次只能检查一个数