题解 | #求解立方根#
求解立方根
https://www.nowcoder.com/practice/caf35ae421194a1090c22fe223357dca
def cube_root_newton(val, tolerance=1e-4): x = val while abs(x**3 - val) >= tolerance: x = 2*x/3 + val/(3*x**2) return round(x, 1) # 读取输入 val = float(input().strip()) # 计算立方根并输出 print(cube_root_newton(val))