写完逻辑树之后,如何输入age值得到结果?
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()