課程
/后端開發
/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 回答代碼應該怎么寫???
5 回答0~3以內的偶數和 怎么輸出是6???
2 回答源代碼中的index起到什么作用
2 回答這句代碼怎么理解
1 回答else:結尾代碼怎么解釋的?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
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')