Python编程:从入门到实践的动手试一试答案(第七章)
来源:互联网 发布:电视会被网络取代吗 编辑:程序博客网 时间:2024/05/21 16:09
#7-1 汽车租赁car = input("What car do you need: ")print('Let me see if I can find you a' + car)
#7-2 餐馆订位inquiry = input("Excuse me, how many people to have dinner: ")if int(inquiry) > 8: print('没空桌')else: print('有空桌')
#7-3 10的整数倍inquiry = input("请输入一个数字: ")if int(inquiry) % 10 == 0: print('是10的整数倍')else: print('不是10的整数倍')
#7-4 比萨配料active = Truewhile active: inquiry = input("请输入你想要的披萨配料: ") if inquiry == 'quit': active = False else: print('我们将加入该配料')
#7-5 电影票active = Truewhile active: age = input("请输入你年龄: ") if int(age) < 3: print('免费') elif int(age) < 12: print('$10') else: print('$15')
#7-6 三个出口active = Truewhile active: inquiry = input("请输入你想要的披萨配料: ") if inquiry == 'quit': break else: print('我们将加入该配料')
#7-7 无限循环active = Truewhile active: print('hello world')
#7-8 熟食店sandwich_orders = ['apple','banana','milk']finished_sandwiches = []while sandwich_orders: sandwich = sandwich_orders.pop() print('I made your ' + sandwich + 'sandwich') finished_sandwiches.append(sandwich)print(finished_sandwiches)
#7-9 五香烟熏牛肉(pastrami)卖完了sandwich_orders = ['apple','pastrami','banana','pastrami','milk','pastrami']finished_sandwiches = []print('五香烟熏牛肉(pastrami)卖完了')while 'pastrami' in sandwich_orders: sandwich_orders.remove('pastrami')while sandwich_orders: sandwich = sandwich_orders.pop() print('I made your ' + sandwich + 'sandwich') finished_sandwiches.append(sandwich)print(finished_sandwiches)
#7-10 梦想的度假胜地places = {}polling_active = Truewhile polling_active: name = input("\nWhat is your name? ") response = input("If you could visit one place in the world, where would you go?") places[name] = response repeat = input("Would you like to let another person respond? (yes/ no) ") if repeat == 'no': polling_active = Falseprint("\n--- Poll Results ---")for name, response in places.items(): print(name + " would like to " + response + ".")
阅读全文
1 0
- Python编程:从入门到实践的动手试一试答案(第七章)
- Python编程:从入门到实践的动手试一试答案(第七章)
- Python编程:从入门到实践的动手试一试答案
- Python编程:从入门到实践的动手试一试答案(第二章)
- Python编程:从入门到实践的动手试一试答案(第三章)
- Python编程:从入门到实践的动手试一试答案(第四章)
- Python编程:从入门到实践的动手试一试答案(第五章)
- Python编程:从入门到实践的动手试一试答案(第六章)
- Python编程:从入门到实践的动手试一试答案(第八章)
- Python编程:从入门到实践的动手试一试答案(第九章)
- Python编程:从入门到实践的动手试一试答案(第十章)
- Python编程:从入门到实践的动手试一试答案(第十一章)
- Python编程:从入门到实践的动手试一试答案(第十一章)
- Python编程:从入门到实践的动手试一试答案(第九章)
- Python编程:从入门到实践的动手试一试答案(第六章)
- Python编程:从入门到实践的动手试一试答案(第十章)
- Python编程:从入门到实践的动手试一试答案(第四章)
- Python编程:从入门到实践的动手试一试答案(第三章)
- 软考错题总结
- iOS 中实现绑定变化的 思路
- LDAP管理工具phpldapadmin(推荐)
- JS复习 -- 作用域链
- 1-5·Linux中帮助命令
- Python编程:从入门到实践的动手试一试答案(第七章)
- OpenCV计算机视觉编程攻略(第2版)代码
- Android显示原理简介(阿里巴巴)
- 1306. Sorting Algorithm
- xampp浏览器不能直接访问本地127.0.0.1,报错Something is wrong with the XAMPP installation :-(
- Maven deploy配置方法
- python文件批量改名
- 欢迎使用CSDN-markdown编辑器
- Android java常用的正则表达式