您的位置:首页 > 编程语言 > Python开发

《Python编程——从入门到实践》第七章部分习题解

2018-03-29 21:45 579 查看
# 7-2
num = input('How many people are going to have dinner?')
num = int(num)
if num >= 8:
print('There is no empty table.')
else:
print('There are some empty tables.')

# 7-5
while True:
age = input('How old are you?')
age = int(age)
if age < 3 and age >= 0:
print('Price : Free')
elif age >= 3 and age < 12:
print('Price : 10 dollars')
elif age >= 12:
print('Price : 15 dollars')

# 7-8
sandwich_orders = ['No.1 sandwich' , 'No.2 sandwich' , 'No.3 sandwich']
finished_sandwich = []
while sandwich_orders:
current_sandwich = sandwich_orders.pop()
print('I made your ' + current_sandwich)
finished_sandwich.append(current_sandwich)
print(finished_sandwich)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: