Python开发【第二篇】运算符

"+" 加号

__author__ = 'Tang'

a = 8
b = 9
c = a + b
print(c) # a = 8.0
b = 9
c = a + b
print(c) # 17.0 a = 8
b = 9.0
c = a + b
print(c) # 17.0

“-” 减号

__author__ = 'Tang'

# 正数
a = 9
b = 8
c = a - b
print(c) # a = 9.0
b = 8
c = a - b
print(c) # 1.0 a = 9
b = 8.0
c = a - b
print(c) # 1.0 # 负数
a = 8
b = 9
c = a - b
print(c) # -1 a = 8.0
b = 9
c = a - b
print(c) # -1.0 a = 8
b = 9.0
c = a - b
print(c) # -1.0

"*" 乘号

__author__ = 'Tang'

a = 9
b = 8
c = a * b
print(c) # a = 9.0
b = 8
c = a * b
print(c) # 72.0 a = 9
b = 8.0
c = a * b
print(c) # 72.0

"/" 除号

__author__ = 'Tang'

a = 9
b = 3
c = a / b
print(c) # 3.0 a = 9.0
b = 3
c = a / b
print(c) # 3.0 a = 9
b = 3.0
c = a / b
print(c) # 3.0 a = 9
b = 8
c = a / b
print(c) # 1.125 a = 9.0
b = 8
c = a / b
print(c) # 1.125 a = 9
b = 8.0
c = a / b
print(c) # 1.125

"%" 求余


__author__ = 'Tang'

a = 9
b = 3
c = a % b
print(c) # 0 a = 9.0
b = 3
c = a % b
print(c) # 0.0 a = 9
b = 3.0
c = a % b
print(c) # 0.0 a = 9
b = 8
c = a % b
print(c) # 1 a = 9.0
b = 8
c = a % b
print(c) # 1.0 a = 9
b = 8.0
c = a % b
print(c) # 1.0

"**" 次方

__author__ = 'Tang'

a = 9
b = 3
c = a ** b
print(c) # a = 9.0
b = 3
c = a ** b
print(c) # 729.0 a = 9
b = 3.0
c = a ** b
print(c) # 729.0

"//" 取整

__author__ = 'Tang'

a = 9
b = 3
c = a // b
print(c) # a = 9.0
b = 3
c = a // b
print(c) # 3.0 a = 9
b = 3.0
c = a // b
print(c) # 3.0 a = 5
b = 2
c = a // b
print(c) # a = 5.0
b = 2
c = a // b
print(c) # 2.0 a = 5
b = 2.0
c = a // b
print(c) # 2.0
上一篇:5G的真正价值


下一篇:ORM对象/关系模型