


CodePudding user response:
Are you sure is the python language?CodePudding user response:
Completion by the implementation of the arithmetic square root, the x value cannot be changed! The completion variable, and use Python to write out!CodePudding user response:
So don't know if it can, reference# precondition: x & gt;=0
Def SQRT (x) :
Assert (x & gt;=0)
Y=0
R=x - y * y
While r & gt; Y + 1=2 * :
Y +=1
R=x - y * y
Assert (y * y & lt;=x <(y + 1) * (y + 1))
Return y
# postcondition: y ^ 2 & lt;=x <(y + 1) ^ 2
If __name__=="__main__" :
X=123.456
Y=SQRT (x)
Print (f '{} y ^ 2 & lt;={x} & lt; {y + 1} ^ 2 ')