第6课时:python之常用操作符

来源:互联网 发布:天元律师事务所 知乎 编辑:程序博客网 时间:2024/06/07 00:23

+,-,*,/(除法),//(除法取商),**(幂运算)

10/8=1.25

10//8=1

双目操作符比左边的优先级高比右边操作符低

and,or,not

>>> -3**2

-9

>>> -(3**2)

-9

>>> 4**-2

0.0625

>>> 4**(-2)

0.0625

优先级顺序高低


4. 请用最快速度说出答案:not1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9 

not > and > or  我们按照优先级给它们加上括号:(not1) or (0 and 1) or (3 and 4) or (5 and 6) or (7 and 8 and 9)

== 0 or 0 or 4 or 6 or 9

== 4

这里注意andor运算后的值不是布尔类型的值,而是实际值


0 0
原创粉丝点击