在命令模式下,除了一般的加减乘除
1、要使两个 float 类型的数据相除后得到整数,可以用 // 符号
2、% 用于取余数
>>> 17 / 3 # classic division returns a float
5.666666666666667
>>>
>>> 17 // 3 # floor division discards the fractional part
5
>>> 17 % 3 # the % operator returns the remainder of the division
2
>>> 5 * 3 + 2 # result * divisor + remainder
17
3、使用 ** 取幂次方
>>> 5 ** 2 # 5 squared
25
>>> 2 ** 7 # 2 to the power of 7
128
同时,对于 -3**2,因为 ** 比 - 号有更高的优先级,所以实际的结果是 -(3**2) = -9;所以如果想得到 9,可以使用括号:(-3)**2
4、最后一个神奇的符号 _ (在交互模式下) 表示刚刚显示在终端的数据
5、除了 int 和 float 类型之外,还有其他 number 类型,例如 Decimal 和 Fraction,Python 同时内置支持 complex numbers 复数,使用 j 或者 J 表示虚数部分的前缀