Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 585 Bytes

198.md

File metadata and controls

28 lines (24 loc) · 585 Bytes
@author jackzhenguo
@desc
@tag
@version 
@date 2020/04/05

1 常见算术运算

x, y = 3, 2
print(x + y) # = 5 
print(x - y) # = 1 
print(x * y) # = 6 
print(x / y) # = 1.5 
print(x // y) # = 1 
print(x % y) # = 1 
print(-x) # = -3 
print(abs(-x)) # = 3 
print(int(3.9)) # = 3 
print(float(x)) # = 3.0 
print(x ** y) # = 9

大多数操作符都是不言自明的。注意,//运算符执行整数除法。结果是一个向下舍入的整数值(例如,3//2==1)

[上一个例子](197.md) [下一个例子](199.md)