iT邦幫忙

2021 iThome 鐵人賽

DAY 6
0
自我挑戰組

Python 基礎學習之旅系列 第 6

Day -6 條件式

python 條件式 if,注意 python run code 是 依據 code 排版 ,前後順序要正確不然有可能出現錯誤。

https://ithelp.ithome.com.tw/upload/images/20210919/20130598IqTiGRuY6s.png

  • if elif else 範例如下:

https://ithelp.ithome.com.tw/upload/images/20210919/2013059853F9Kj4ilR.png

  • if-else
    https://ithelp.ithome.com.tw/upload/images/20210919/20130598mjz2tvZ2eT.png

https://ithelp.ithome.com.tw/upload/images/20210919/20130598xPrwajSWEf.png

-多個條件時
and:所有條件都成立才為True,否則為False
or: 任一條件成立就為True,否則為False

https://ithelp.ithome.com.tw/upload/images/20210919/20130598eypbN6LbIC.png

  • in來做判斷
    https://ithelp.ithome.com.tw/upload/images/20210919/20130598F1xbEBObmp.png

上一篇
Day-5 註解與斷行
下一篇
Day-7 字串(上)
系列文
Python 基礎學習之旅12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言