課程
/后端開發
/Python
/Python3 入門教程(新版)
寫完邏輯樹之后,如何輸入age值得到結果?
2022-02-09
源自:Python3 入門教程(新版) 4-3
正在回答
age?=?eval(input('請輸入年齡')) if?age?>=?18: ????print('adult') elif?age?>=?6: ????print('teenager') elif?age?>=?3: ????print('kid') else: ????print('baby')
age?=?int(input("請輸入年齡:")) if?age?<=?6: ????if?age?<=?3: ????????print("baby") ????else: ????????print("kid") elif?age?<=?18: ????print("teenager") else: ????print("adult")
age = input('請輸入你的年齡:')
if int(age)>=18:
? ? print('你的年齡是:{},adult'.format(age))
elif int(age)>=6:
? ? print('你的年齡是:{},teenager'.format(age))
elif int(age)>=3:
? ? print('你的年齡是:{},kid'.format(age))
else:
? ? print('你的年齡是:{},baby'.format(age))
使用input()函數可以接收任意age,然后將它保存在變量里qwq例如:
age = input()
MakerFly
qq_慕慕2529740
weixin_慕妹7508848
weixin_慕瓜0570812 回復 weixin_慕妹7508848
舉報
python3入門教程,讓你快速入門并能編寫簡單的Python程序
2 回答或運算中,如果兩個都為T,輸出前面還是后面
3 回答與運算99 and 98什么結果
1 回答布爾類型運算結果答疑
2 回答根據與運算,兩個布爾值都為true,結果必定是true。為什么輸出world,不輸出pd。
3 回答輸出結果疑問
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2022-06-28
2022-06-07
2022-04-29
age = input('請輸入你的年齡:')
if int(age)>=18:
? ? print('你的年齡是:{},adult'.format(age))
elif int(age)>=6:
? ? print('你的年齡是:{},teenager'.format(age))
elif int(age)>=3:
? ? print('你的年齡是:{},kid'.format(age))
else:
? ? print('你的年齡是:{},baby'.format(age))
2022-02-10
使用input()函數可以接收任意age,然后將它保存在變量里qwq例如:
age = input()