题目描述
注意Python 保留小数的写法
old_num = 1.23456
new_num = '%.2f' % old_num
new_num1 = '%.3f' % old_num
print('保留2位小数结果:', new_num)
print('保留3位小数结果:', new_num1)
Python 代码
if __name__ == '__main__':
n = float(input())
l,r = -10000,10000
while r - l>10**-8:
mid= (l+r)/2
if mid**3<n:
l = mid
else:
r = mid
print("%.6f"%l)