Boolean operators:
- not, and, or: 优先级从左到右
- Keep in mind that and and or don’t always return booleans when using values other than True and False
-
short-circuiting:
- 先判断第一个expression是不是符合,如果是则直接输出。
- For example, and will short-circuit as soon as it reaches the first false value because it then knows that not all the values are true.
- If and and or do not short-circuit, they just return the last value.
- 先判断第一个expression是不是符合,如果是则直接输出。
- 负数不是False。比如while循环,如果一直是负数,则无限循环,只有出现0才是False,循环才终止。
写Loops
- 循环终止:要让循环控制变量发生变化达到终止。