-2
编写一个完整的python程序,要求用户输入一个年龄(整数)。如果年龄在18岁以下,该计划输出“轻微”。如果年龄在18岁至67岁之间,则计划输出“工作年龄”。该程序输出“退休时间”,只要年龄超过67读取年龄输入的程序
不知道哪里来的这一个开始。任何想法?
编写一个完整的python程序,要求用户输入一个年龄(整数)。如果年龄在18岁以下,该计划输出“轻微”。如果年龄在18岁至67岁之间,则计划输出“工作年龄”。该程序输出“退休时间”,只要年龄超过67读取年龄输入的程序
不知道哪里来的这一个开始。任何想法?
这是蟒蛇一个非常简单的任务,我会以伪代码让您对如何去写这样的“观念”:
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中非常重要的
试试这个
。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.')