零基础学pyhton之一些常用函数
1、a = abs(-5.7) # abs(x):求x的绝对值print(a, type(a))

2、a = max(3, 6, 8, 9.5, -4, 20) # 找出最大的数print(a)

3、a = min(4, 2, 5, 6) # 找出最小的数print(a)

4、a = pow(4, 2, 5) # pow(x,y):x**y, pow(x,y,z):x**y%zprint(a)

5、# round(x)对x 四舍五入取整。如果整数部分为偶数,并且小数部分是0.5,那么这个0.5会舍去a = round(6.5001)print(a)

6、# round(x, y)保留小数点后y位。a = round(6.31231, 2)print(a)

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:85
阅读量:122
阅读量:111
阅读量:155
阅读量:178