#求商运算
>>>8/2
4
#整除,仅保留整数
>>>8//3
2
#求余运算,等价于:x%y=x-((x//y)*y)
>>>8%3
1
#乘方运算
>>>8**2
64
>>>pow(2,3)
8
#赋值实例
>>>x=input("x:")
x:3
>>>y=input("y:")
y:4
>>>print(int(x)*int(y))
12
#求绝对值
>>>abs(-8)
8
#求浮点数最接近的整数
>>>round(8.567)
9.0
#导入模块 使用import命令,如import math,再以 math.function的方式使用模块中的函数。
>>>import math #导入命令
>>>math.floor(9.8888) #浮点数最接近的最小整数
9
>>>math.ceil(9.111)
10
>>>math.sqrt(9)
3.0
>>>
网友评论