第四周作业a 第7章选做(2、5、6、8)

本文提供了几个简单的Python程序实例,包括检查餐厅是否有空桌、票价计算系统及三明治订单处理等,通过这些示例帮助读者理解条件判断和循环结构。
7-2
number=int(input("How many people will have a meal?:"))
if number>8:
	print("There is no empty table for so many people.")
else:
	print("There is an empty table.")


7-5/6

flag=True
while(flag):
	age=input("Please input the age or 'quit' :")
	if age=='quit':
		print("Quited")
		break
	else:
		age=int(age)
	if age<3:
		print("The ticket is free.")
	elif age>=3 or age<12:
		print("The ticket is $10.")
	elif age>=12:
		print("The ticket is $12.")



7-8

sandwich_orders=["A","B","C"]
finished_sandwiches=[]
while sandwich_orders:
	print("I made you sandwich:"+sandwich_orders[0])
	finished_sandwiches.append(sandwich_orders[0])
	del sandwich_orders[0]
print(finished_sandwiches)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值