《Python编程-从入门到实践》课后习题(6)
2018-03-26 08:45
776 查看
7-1
car = input('What kind of car do you want?\n') print('Let me see if I can find you a '+car)
7-2
seats = input('How many seats do you want?\n') seats = int(seats) if seats>8: print('No suitable tables') else: print('There is a available table')
7-3
num = input('Input a number: ') if int(num)&10: print('The number '+num+" isn't 10's multiple") else: print('The number '+num+" is 10's multiple")
7-4
thing = input('What do you want to add in the pizza?\n') while thing!='quit': print('We will add '+thing+' to the pizza.\n') thing = input('What else do you want to add?\n')
7-5
age = input('How old are you?: ') if int(age)<3: print('You age is '+age+' and you are free') elif int(age)>=3 and int(age)<=12: print('You age is '+age+' and you need pay $10') elif int(age)>12: print('You age is '+age+' and you need pay $15')
7-7
while True: i = 1
7-8
sandwich_orders = ['A', 'B', 'C'] finished_sandwichs = [] while sandwich_orders: sandwich = sandwich_orders.pop() print('I made you '+sandwich) finished_sandwichs.append(sandwich)
7-9
sandwich_orders = ['A', 'B', 'C', 'pastrami', 'pastrami', 'pastrami'] print('Pastramis are sold out') while 'pastrami' in sandwich_orders: sandwich_orders.remove('pastrami') finished_sandwichs = [] while sandwich_orders: sandwich = sandwich_orders.pop() print('I made you '+sandwich) finished_sandwichs.append(sandwich)
7-10
destis = [] message = '' while message!='quit': message = input('If you could visit one place in the world, where would you go?\n') destis.append(message) print('The result is:') for desti in destis: print(desti)
相关文章推荐
- 《Python编程 从入门到实践》第八章课后习题
- Python编程:从入门到实践(课后习题5)
- 《Python编程-从入门到实践》课后习题(2)
- 《Python编程 从入门到实践》第十章课后习题
- Python编程:从入门到实践(课后习题6)
- 《Python编程 从入门到实践》第三章课后习题
- Python编程:从入门到实践(课后习题7)
- 《Python编程 从入门到实践》第九章课后习题
- Python编程:从入门到实践(课后习题8)
- 《Python编程 从入门到实践》第二章课后习题
- 《Python编程-从入门到实践》课后习题(1)
- 《Python编程 从入门到实践》第五章课后习题
- 《Python编程-从入门到实践》课后习题(5)
- 《Python编程-从入门到实践》课后习题(7)
- Python编程:从入门到实践(课后习题9)
- 《Python编程 从入门到实践》第六章课后习题
- Python编程:从入门到实践(课后习题11)
- Python编程:从入门到实践(课后习题10)
- 《Python编程-从入门到实践》课后习题(8)
- 《Python编程 从入门到实践》第七章课后习题