2015-03-31 64 views
-2

編寫一個完整的python程序,要求用戶輸入一個年齡(整數)。如果年齡在18歲以下,該計劃輸出「輕微」。如果年齡在18歲至67歲之間,則計劃輸出「工作年齡」。該程序輸出「退休時間」,只要年齡超過67讀取年齡輸入的程序

不知道哪裏來的這一個開始。任何想法?

回答

0

這是蟒蛇一個非常簡單的任務,我會以僞代碼讓您對如何去寫這樣的「觀念」:

ask the user for an input (look up raw_input) 
#start an if-elif block 
if age < 18 
    print your message here 
elif age is greater than or equal 18 and age is greater than or equal 67 
    print your message here 
else 
    print your message here 

確保您縮進打印報表的Python中非常重要的

0

試試這個

age = int(input('Enter your age: ')) 
if age < 18: 
    print('You are a minor and not eligible to work in this City.') 
elif age >= 18 and age <= 67: 
    print('Hoooray, you are eligible to work in this City.') 
else: 
    print('Go ahead. Just retire now.')