Python开发【第二篇】运算符
"+" 加号
__author__ = 'Tang'a = 8
b = 9
c = a + b
print(c) # 17
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) # 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
# 负数
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) # 72
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) # 729
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) # 3
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) # 2
a = 5.0
b = 2
c = a // b
print(c) # 2.0
a = 5
b = 2.0
c = a // b
print(c) # 2.0
以上是 Python开发【第二篇】运算符 的全部内容, 来源链接: utcz.com/z/387556.html