py第七章习题
2018-04-01 10:49
204 查看
#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 + '.')
相关文章推荐
- py第七章习题
- 第七章课后习题
- 算法竞赛入门第七章:习题
- 算法导论第七章习题答案(第三版) Introduction to Algorithm
- 第七章习题G题
- C++程序设计课后习题及解答(第七章)
- 算法导论课后习题解析 第七章
- python 核心编程 第七章习题
- c++ primer(第五版)学习笔记及习题答案代码版(第七章)类
- c++ primer 第五版----第七章习题解答
- 【《Python编程: 从入门到实践》习题答案--第七章:<用户输入和while 循环>】
- 第七章 人力资源管理概述习题解答
- 《高级编程技术》作业[7]——第七章部分习题选做
- 第七章 灵活运用寻址方式(si/di和内嵌套循环)——所有的习题练习
- Learn Python The Hard Way-习题48 lexicon.py之我的实现
- 快学scala 第七章 包和引入 读书笔记及习题答案代码
- 第七章习题汇总
- 第七章部分习题
- 第七章 人力资源管理概述习题解答
- 【第四周】第七章习题