题目转载:http://python.wzms.com/s/1/118
题目描述:
某旅游景点规定,身高在1.2米以下的儿童免票,身高1.2~1.5米(包含1.2米和1.5米)的儿童购买半价票,身高超过1.5米的游客购买全价票。
输入格式:
一个实数
输出格式:
输出一行,表示购买票的情况(free、half-price ticket、full ticket)。
代码:
stature = float(input('请输入儿童的身高(单位:米):'))
if stature < 1.2:
print('free')
elif stature <= 1.5:
print('half-price ticket')
else:
print('full ticket')
注意:input返回的是字符串,要将返回值转成浮点型数据
运行结果: