【Python-3.3】字典存储调查问卷
来源:互联网 发布:安全风险矩阵 编辑:程序博客网 时间:2024/06/05 16:39
编写一个程序,调查用户梦想的度假胜地。使用类似于“If you could visit one place in the world, where would you go?”的提示,并编写一个打印调查结果的代码块。
代码如下:
responses = {}# 设置一个标志,指出调查是否继续polling_active = Truewhile polling_active: # 提示输入被调查者的名字和回答 name = input("\nWhat's your name? ") response = input("If you could visit one place in the world, where would you go? ") # 将答卷存储在字典中 responses[name] = response # 看看是否还有人要参加调查 repeat = input("Would you like to let another person respond? (yes/no)") if repeat == 'no': polling_active = False #将调查结果打印出来print("\n----- Poll Results -----")for name,response in responses.items(): print(name.title() + " would like to go to " + response.upper() + ".")输出如下:
>>> ================================ RESTART ================================>>> What's your name? liuIf you could visit one place in the world, where would you go? taishanWould you like to let another person respond? (yes/no)yesWhat's your name? dongIf you could visit one place in the world, where would you go? huangshanWould you like to let another person respond? (yes/no)no----- Poll Results -----Dong would like to go to HUANGSHAN.Liu would like to go to TAISHAN.
阅读全文
0 0
- 【Python-3.3】字典存储调查问卷
- 调查问卷
- 免费调查问卷 调查问卷投票系统
- 【Python-3.3】字典中存储字典
- 如何设计调查问卷
- 大学生旅游调查问卷
- 如何设计“调查问卷”
- 包装设计调查问卷
- 生活水平调查问卷
- Moss调查问卷--仅供参考
- 调查问卷录入spss
- 用户需求调查问卷
- 校园调查问卷网站
- JavaScript实现调查问卷
- 用户调查问卷
- 调查问卷数据库设计
- 调查问卷实例
- Android调查问卷
- BP神经网络拟合函数
- UVA 136 Ugly Number(优先队列)
- jQuery--1.基本概念
- AVL树介绍与实现
- 一些优秀的开源项目
- 【Python-3.3】字典存储调查问卷
- semantic取代bootstrap
- 简单入门小程序02
- [uva-336] A Node Too Far(BFS
- python脚本抓取天气信息并发给微信好友
- Linux学习笔记第2天
- django将所有app放到一个apps文件夹中
- 打印100~200 之间的素数
- HDU