Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何解释我的平方根程序_Python_Python 2.7 - Fatal编程技术网

Python 如何解释我的平方根程序

Python 如何解释我的平方根程序,python,python-2.7,Python,Python 2.7,我的平方根程序是如何解释的,因为它似乎没有给我答案 def square_root(f): g=f while g**2!=f: g = 1.5*(g+f/g) return g 它不工作,因为这部分g=1.5*(g+f/g)是错误的 def square_root(f): g = f while g**2 > f: g = 0.5*(g+f/g) return g 看看我的功能: 你的一个: 请编辑您的问

我的平方根程序是如何解释的,因为它似乎没有给我答案

def square_root(f):
    g=f
    while g**2!=f:
        g = 1.5*(g+f/g)
    return g

它不工作,因为这部分
g=1.5*(g+f/g)
是错误的

def square_root(f):
    g = f
    while g**2 > f:
        g = 0.5*(g+f/g)
    return g
看看我的功能: 你的一个:

请编辑您的问题,以显示您提供的输入和输出。看起来您忘记调用您定义的函数了。