py第七章习题

#7-1
car = input('Which car do you want?\n')
print('Let me see if I can find you a ' + car + '.')

#7-2
peo = input('How many people comes to have supper? ')
peo = int(peo)
if peo > 8:
	print('Sorry, we don`t have so large table.')
else:
	print('Welcome!')
print()
#7-3
num = input('Input a num.')
num = int(num)
if num % 10 == 0:
	print(str(num) + ' can be divide by ten')
else:
	print(str(num) + ' can`t be divide by ten')
print()
#7-4
pizza = []
ing = input('Please input an ingredients what you want to add to your pizza: ')
while ing != 'quit':
	pizza.append(ing)
	print('We will input the '+ ing +' into your pizza~!')
	ing = input('Please input another ingredient what you want to add to your pizza: ')
print('We have add ' + ','.join(pizza) + ' to the pizza')
#7-5
while True:
	age = input('How old are you? (input "-1" to quit)\n')
	age = int(age)
	if age == -1:
		break
	if age < 3:
		print('FREE!')
	elif age >= 3 and age <= 12:
		print('10$!')
	else:
		print('15$')
#7-7
while True:
	print('HaHaHahahaha23333')

#7-8
sandwich_orders = ['cheese','potato','chicken','beef']
finished_sandwiches = []
while sandwich_orders:
	print('I made you ' + sandwich_orders[0] + ' sandwich.')
	finished_sandwiches.append(sandwich_orders[0])
	del sandwich_orders[0]
print('I have made ' + ' sandwich, '.join(finished_sandwiches) + ' sandwich.')
#7-9
sandwich_orders = ['cheese','potato','chicken','pastrami','pastrami','pastrami','beef']
finished_sandwiches = []
print('Sorry, we have no pastrami already.')
while 'pastrami' in sandwich_orders:
	sandwich_orders.remove('pastrami')
while sandwich_orders:
	print('I made you ' + sandwich_orders[0] + ' sandwich.')
	finished_sandwiches.append(sandwich_orders[0])
	del sandwich_orders[0]
print('I have made ' + ' sandwich, '.join(finished_sandwiches) + ' sandwich.')

#7-10
responses = {}
while True:
	name = input('What`s your name?\n')
	place = input('If you could visit one place in the world, where would you go?\n')
	
	responses[name] = place
	
	repeat = input('Would you like to let another person respond?(yes/no)')
	if repeat == 'no':
		break
	
print('-------------Result----------------')
for name,place in responses.items():
	print(name.title() + ' want to go to ' + place + '.')






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值