7.31 PY basis of flow control (IF determination)

7.31 PY basis of flow control (IF determination)

if the judge is doing it? In fact, if the judge is to make a judgment in the simulation of people. If that is so what, so what if.

effect

Determination condition is satisfied, the execution code block, otherwise, the other code blocks

Show

if…else

if 条件:
    代码块1
else:
    代码块2        

if...elif...else

if 条件1:
    代码块1
    ...
elif 条件2:
    代码块2
    ...
elif 条件3:
    代码块3
    ...
...   # 可以有N个elif判断
else:
    代码块4

if nesting

if 条件1:
    代码块1
    if 条件2:
        代码块2
    else:
        代码块3
else:
    代码块4

use

By the age of guessing games may be familiar if conditional statement, details see another blog

https://www.cnblogs.com/dadazunzhe/p/11265715.html

Guess you like

Origin www.cnblogs.com/dadazunzhe/p/11277434.html