欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

python筆記3

系統(tǒng) 1632 0
閱讀更多
####if語(yǔ)句###
cars=['audi','bmw','subaru','toyota']
for car in cars:
if car=='bmw':?? #==檢查是否相等? 即相等時(shí)返回Ture,不相等時(shí)返回Flase
print(car.upper())
else:
print(car.title())

cars=['audi','bmw','subaru','toyota']
for car in cars:
if car !="bmw":?? #!=檢查是否不相等? 即不相等時(shí)返回Ture,相等時(shí)返回Flase
print(car.upper())
else:
print(car.lower())

#補(bǔ)python終端檢查是否相等
#>>>car='bmw'
#>>>car=='bmw'則輸出Ture 否則返回Flase, !=同理

#if例子
#檢查一個(gè)人是否是20歲(單個(gè)條件)
answer=18??
if answer!=20:? #當(dāng)然條件可以是大于小于等等 <,>,<=,>=,等等
print('That id not the correct answer,Please try again!')

#檢查多個(gè)條件 and ###關(guān)鍵字or與and類似 不予列舉
answer=18??
if answer>=17 and answer<=20:
print('That id not the correct answer,Please try again!')
#靈活運(yùn)用 可對(duì)多個(gè)人進(jìn)行檢查
answer_1=18
answer_2=20?
if answer_1>=16 and answer_1<=20 and answer_2<30:
print('That id not the correct answer,Please try again!')

##檢查特定值是否在列表中:可利用python終端來(lái)執(zhí)行##
#1.>>>cars=['audi','bmw','subaru','toyota']
#>>>"bmw" in cars
#2.
cars=['audi','bmw','subaru','toyota']
car='bmw'
if car in cars:? #in前加not即沒有在列表內(nèi)
print(car.title()+' '+"in the list")
######
#if-elif-else結(jié)構(gòu) ##只能測(cè)試指定一個(gè)條件(通過(guò)一個(gè)測(cè)試條件將跳過(guò)余下的測(cè)試)#
#可根據(jù)需要使用任意數(shù)量的elif代碼塊
age=15
if age<4:
price=0 #print("Your admission cost is $0")
elif age<18:
price=5? #print("Your admission cost is $5")
else:
price=10? #print("Your admission cost is $10")
print("Your admission cost is $"+str(price)+".")#str()函數(shù):將某一個(gè)類型強(qiáng)制轉(zhuǎn)換為字符串型。如,a = 1,a的類型就是數(shù)值型,a = str(a),a就是字符串型了
##測(cè)試多個(gè)條件
print('\n')
requested_toppings=['mushrooms','extra cheese']
if 'mushrooms' in requested_toppings:
print("Adding mushrooms.")
if 'extra cheese' in requested_toppings:
print("Adding extra cheese.")
if 'pepperoni' in requested_toppings:
print("Adding pepperoni.")
print("Finished making your pizza!")
#與for循環(huán)連用 (檢查列表元素中有無(wú)特殊元素)
#披薩店滿足顧客的單個(gè)條件
print('\n')
requested_toppings=['mushrooms','extra cheese','pepperoni','green pappers']
for requested_topping in requested_toppings:
if requested_topping=='pepperoni':
print("Sorry,we are out of pepperoni right now.")
else:
print('Adding '+requested_topping+'.')
print('Finished making your pizza!')
#披薩店滿足顧客的多個(gè)條件
print('\n')
available_toppings=['mushrooms','extra cheese','pepperoni','green pappers','olives']
requested_toppings=['mushrooms','extra cheese','pineapple']
for requested_topping in requested_toppings:
if requested_topping in available_toppings:
print('Adding '+requested_topping+'.')
else:
print("Sorry,we don't have"+requested_topping+'.')
#判斷列表是否為空
print('\n')
requested_toppings=[]
if requested_toppings:? #如果該列表為空時(shí)返回False;至少有一個(gè)元素時(shí)返回True,進(jìn)行下面的for循環(huán)
? for requested_topping in requested_toppings:
? print('Adding '+requested_topping+'.')
else:
print("Are you sure you want a plain pizza?")

更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 无限资源动漫精彩日本 | 国产综合久久 | 久久国产精品视频 | 在线看免费观看日本 | 福利视频1000 | 十六以下岁女子毛片免费 | 成人欧美视频在线观看 | 久久精品免费一区二区三区 | 夜夜操狠狠干 | 一区二区在线 | 免费看特黄特黄欧美大片 | 国产欧美日韩在线不卡第一页 | 国产在线精品一区二区高清不卡 | 日本玖玖 | 在线观看亚洲精品 | 成人颜色视频 | 狠狠干91 | 天天操天天操天天 | 日韩欧美一区二区三区在线视频 | 国产欧美曰韩一区二区三区 | 性夜影院爽黄a爽免费视 | 久久伊人色综合 | 成年人免费网站视频 | www.日韩av.com | 国产美女高潮 | 欧美一区欧美二区 | 日韩高清免费在线观看 | 色屋视频 | 欧美日日日 | 一区二区三区四区在线 | 欧美日皮视频 | 日韩在线精品视频 | www.久久精品 | 嫩草视频在线观看 | 国产亚洲精品久久久久久久网站 | 久久99色| 蜜臀AV在线观看 | 老头天天吃我奶躁我午夜视频 | 91国在线观看 | 麻豆短视频传媒网站怎么找 | 超碰人人人 |