第七章练习题

7-1

type = raw_input("Which car would you like?")
print("Let me see if I can find you a " + type + ".")
Which car would you like?bwm
Let me see if I can find you a bwm.
------------------
(program exited with code: 0)

7-2

number = raw_input("How many seats do you need?")
if int(number) > 8:
	print("There is no empty table.")
else:
	print("There is an empty table")
How many seats do you need?6
There is an empty table
------------------
(program exited with code: 0)
How many seats do you need?9
There is no empty table.
------------------
(program exited with code: 0)

7-5

active = True
while active:
	age = raw_input("How old are you?")
	if age == 'quit':
	   active = False
	else:
	   if int(age) < 3:
		    print("Free.")
	   elif int(age) <= 12:
		    print("$10.")
	   elif int(age) > 2:
	    	print("$15.")
How old are you?4
$10.
How old are you?2
Free.
How old are you?19
$15.
How old are you?quit

------------------
(program exited with code: 0)

7-8

sandwich_orders = ['beef','sheep','fruit','yogurt']
sandwich = ""
while sandwich_orders:
	sandwich = sandwich_orders.pop()
	print("I made you " + sandwich + " sandwich.")
I made you yogurt sandwich.
I made you fruit sandwich.
I made you sheep sandwich.
I made you beef sandwich.


------------------
(program exited with code: 0)





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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值