- 算术运算符
''' @note: https://www.runoob.com/python/python-operators.html @author: xilh @since: 20200124 ''' a = 21 b = 10 c = 0 c = a + b print("a + b 的值为:", c) c = a - b print("a - b 的值为:", c) c = a * b print("a * b 的值为:", c) c = a / b print("a / b 的值为:", c) c = a % b print("a % b 的值为:", c) # 修改变量 a 、b 、c a = 2 b = 3 c = a**b print("a**b 的值为:", c) a = 10 b = 5 c = a//b print("a//b 的值为:", c)
- 运行结果
a + b 的值为: 31 a - b 的值为: 11 a * b 的值为: 210 a / b 的值为: 2.1 a % b 的值为: 1 a**b 的值为: 8 a//b 的值为: 2