Python 條件式 Condition
作者:互联网
除了重複使用Function,有時我們須檢查結果,依此判斷下個步驟該怎麼進行,如此就需要條件式 condition statement。
if ... elif ... ese ( 或 if ... elif ...elif 或 if .. else )
>>> 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
标签:even,...,elif,條件,numIsEven,Python,print,odd,Condition 来源: https://www.cnblogs.com/chingchangmeng/p/11383958.html