题解 | #小数位修正#
小数位修正
https://www.nowcoder.com/practice/ee78c92efbcc489699141ec4d0b80ac1
a=float(input()) print(round(a,2)) # round() 方法返回浮点数x的四舍五入值 print(round(123.45)) 当参数n不存在时,round()函数的输出为整数。 print(round(123.65,0)) 当参数n存在时,即使为0,round()函数的输出也会是一个浮点数。print(round(123.45,-1)) 此外,n的值可以是负数,表示在整数位部分四舍五入,但结果仍是浮点数。 123 124.0 120.0