统计年龄人数
从键盘输入一组年龄存入列表中,统计35岁(含35岁)以下年龄段、35岁到59(含59岁)年
龄段和60岁以上年龄段的人数,并输出。
输入格式:输入一行以空格分隔的年龄值。
输出格式:输出各年龄段人数,参看输入输出示例。
输入样例:12 67 55 70 45 40
输出样例:less than and equal 35:1
35 to 60:3
bigger than and equal 60:2
统计年龄人数
从键盘输入一组年龄存入列表中,统计35岁(含35岁)以下年龄段、35岁到59(含59岁)年
龄段和60岁以上年龄段的人数,并输出。
输入格式:输入一行以空格分隔的年龄值。
输出格式:输出各年龄段人数,参看输入输出示例。
输入样例:12 67 55 70 45 40
输出样例:less than and equal 35:1
35 to 60:3
bigger than and equal 60:2
收起
count1 =0
count2 =0
count3 =0
lst = list(map(int, input().split()))
for i in lst:
if i>=0 and i<=35:
count1+=1
elif i>=35 and i<=60:
count2+=1
else:
count3+=1
print('less than and equal 35:{}\n35 to 60:{}\nbigger than and equal 60:{}'.format(count1,count2,count3))
报告相同问题?