課程
/后端開發(fā)
/Python
/Python3 入門教程
if?age?>=?18: ????print('adult') elif?age?['6,8']: ????print('kid')
2021-08-13
源自:Python3 入門教程 4-3
正在回答
Python中可以連著用比較符號,所以年齡三到六歲可以寫成 3 <= age < 6
或者也可以寫成? 3 <= age and age < 6??
age = int(input('請年齡:'))
if age >= 18:
? ? print('adult')
elif age > 6 and age <= 8:
? ? print('kid')
elif age > 3 and age <= 6:? ? ? # 年齡3歲到6歲
? ? print('child')
舉報
python3入門教程,讓你快速入門并能編寫簡單的Python程序
1 回答代碼應(yīng)該怎么寫?。?/p>
5 回答0~3以內(nèi)的偶數(shù)和 怎么輸出是6???
2 回答源代碼中的index起到什么作用
2 回答這句代碼怎么理解
3 回答為什么這樣寫代碼是錯誤的?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2021-10-02
Python中可以連著用比較符號,所以年齡三到六歲可以寫成 3 <= age < 6
或者也可以寫成? 3 <= age and age < 6??
2021-08-14
age = int(input('請年齡:'))
if age >= 18:
? ? print('adult')
elif age > 6 and age <= 8:
? ? print('kid')
elif age > 3 and age <= 6:? ? ? # 年齡3歲到6歲
? ? print('child')