除了重複使用Function,有時我們須檢查結果,依此判斷下個步驟該怎麼進行,如此就需要條件式 condition statement。
if ... elif ... ese ( 或 if ... elif ...elif 或 if .. else )
while
>>> def numIsEven(k):
... if k % 2 == 0:
... print(k,' is even')
... else:
... print(k,' is odd')
...
>>> numIsEven(8)
8 is even
>>> numIsEven(7)
7 is odd
/end