Python基础教程—2019/1/29

2019/1/29

// 整除
** 乘方
0x 十六进制 0b 二进制 0o八进制

常用模块和函数
1:pow() 乘方

pow(2,3)
8
2**3
8

2:abs() 绝对值

3:round() 向最接近的那个数取整,如果一样,向偶数取整

round(2/3)
1

4:math库的floor()函数,向下取整
import math
math.floor(32.9)
32

5:math库的ceil()向上取整

math.ceil(32.9)
33
math.ceil(33)
33

6:sqrt()开平方根

math.sqrt(9)
3.0

导入方式2:
from math import ceil
ceil(32.4)
33

处理虚数的模块 cmath
import cmath
cmath.sqrt(-9)
3j

转载于:https://blog.51cto.com/12884584/2347747

你可能感兴趣的:(Python基础教程—2019/1/29)