计算根到第n个,但错误不断说出非类型错误

时间:2019-02-26 15:23:08

标签: python

我正在尝试找到root到nth-root。我向函数传递了两个浮点数,分别是root和index。但是它一直给我一个错误“'>','NoneType'和'float'的实例之间不支持”

def roots(root, index):
    tp, mid, low = 0.0, 0.0, 0.0
    high = int(root)

    while True:
        mid = (low + high) / 2
        if Power(mid, index) > root:
            high = mid
        else:
            low = mid

        mid = (low + high) / 2
        tp = Power(mid, index) - root

        if tp < 0:
            tp=-tp

        if tp < 0.000005:
            break
    print('Operation: root %.5f of %.5f = %.5f' % (index, root, mid))

0 个答案:

没有答案