小编fra*_*opt的帖子

需要帮助,使用Terminal Run编写一个关于已定义函数的python

我是python的新手,目前正在学习正确使用def函数.

我在Sublime Text中的def代码如下:

def quadratic(a,b,c):
    if not isinstance(a,(int,float)):
        raise TypeError('bad operand type')
    if not isinstance(b,(int,float)):
        raise TypeError('bad operand type')
    if not isinstance(c,(int,float)):
        raise TypeError('bad operand type')
    d = b ** 2 - 4 * a * c
        if d < 0:
            print('no result!')
        if d = 0:
            x1 = -b / (2 * a)
            x2 = x1
            return x1,x2
        else:
            x1 = (-b + math.sqrt(d)) / (2 * a)
            x2 = (-b - math.sqrt(d)) / (2 * a)
            return x1,x2 …
Run Code Online (Sandbox Code Playgroud)

python terminal

-1
推荐指数
1
解决办法
52
查看次数

标签 统计

python ×1

terminal ×1