函数round函数的使用方法
round函数是Python内置的一个数值处理函数,用于对浮点数进行四舍五入。 它的使用方法如下: 1. round(x):对x进行四舍五入,默认保留到整数。 2. round(x, n):对x进行四舍五入,保留n位小数。n可以为负数,表示保留到整数位。 例如: ```python x = 3.1415926 print(round(x)) # 输出:3 y = 3.1415926 print(round(y, 2)) # 输出:3.14 z = 3.1415926 print(round(z...