Python编程:从入门到实践第七章练习7.3

Python编程:从入门到实践第七章练习7.3

#coding:gbk

#7-8熟食店
sandwich_orders = ['a','b','c','d']
finished_sanwiches = []

for sandwich_order in sandwich_orders:
	print("I made your " + sandwich_order.title() + "sandwich.")

while sandwich_orders:
	x = sandwich_orders.pop()
	finished_sanwiches.append(x)
print("\nThe following sandwiches have been finished: ")
for sandwich in finished_sanwiches:
	print(sandwich)
print(finished_sanwiches)#验证新列表的成功导入

#7-9五香烟熏牛肉卖完了
sandwich_orders = ['a','pastrami','b','pastrami','c','pastrami','d']
print("熟食店的五香烟熏牛肉卖完了:")
#print(sandwich_orders)
while 'pastrami' in sandwich_orders:
	sandwich_orders.remove('pastrami')
print(sandwich_orders)
	
#7-10梦想的度假胜地
dream_places = {}

active = True

while active:
	name = input("您的名字:")
	response = input("您梦想的度假胜地是哪里呢?")
	
	dream_places[name] = response  #运用一次键-值对地赋值即可,不用分别对键和值进行赋值
	
	repeat = input("您是否希望另一个人接受调查呢?(是/否)")
	if repeat == "否":
		active = False
print("\n--- 结果 ---")
for name,response in dream_places.items():
	print(name + "希望去" + response)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值