Coursera课程Python for everyone:chapter9
Chapter 9 Quiz
10 试题
How are Python dictionaries different from Python lists?
Python lists maintain order and dictionaries do not maintain order
Python lists can store strings and dictionaries can only store words
Python dictionaries are a collection and lists are not a collection
Python lists store multiple values and dictionaries store a single value
What is a term commonly used to describe the Python dictionary feature in other programming languages?
Lambdas
Sequences
Associative arrays
Closures
What would the following Python code print out?
stuff = dict() print stuff['candy']
0
-1
The program would fail with a traceback
candy
What would the following Python code print out?
stuff = dict() print stuff.get('candy',-1)
0
-1
'candy'
The program would fail with a traceback
(T/F) When you add items to a dictionary they remain in the order in which you added them.
False
True
What is a common use of Python dictionaries in a program?
Building a histogram counting the occurrences of various strings in a file
Splitting a line of input into words using a space as a delimiter
Computing an average of a set of numbers
Sorting a list of names into alphabetical order
Which of the following lines of Python is equivalent to the following sequence of statements assuming that counts is a dictionary?
if key in counts:counts[key] = counts[key] + 1 else:counts[key] = 1
counts[key] = (key in counts) + 1
counts[key] = counts.get(key,-1) + 1
counts[key] = (counts[key] * 1) + 1
counts[key] = key + 1
counts[key] = counts.get(key,0) + 1
In the following Python, what does the for loop iterate through?
x = dict() ... for y in x :...
It loops through all of the dictionaries in the program
It loops through the integers in the range from zero through the length of the dictionary
It loops through the keys in the dictionary
It loops through the values in the dictionary
Which method in a dictionary object gives you a list of the values in the dictionary?
items()
keys()
each()
all()
values()
What is the purpose of the second parameter of the get() method for Python dictionaries?
The value to retrieve
To provide a default value if the key is not found
The key to retrieve
An alternate key to use if the first key cannot be found
Coursera课程Python for everyone:chapter9相关推荐
- Coursera课程Python for everyone:Quiz: Many-to-Many Relationships and Python
Many-to-Many Relationships and Python 9 试题
- Coursera课程Python for everyone:Quiz: Multi-Table Relational SQL
Multi-Table Relational SQL 10 试题 1. What is the primary added value of relational databases over fla ...
- Coursera课程Python for everyone:Quiz: Single-Table SQL
Single-Table SQL 11 试题 1. Structured Query Language (SQL) is used to (check all that apply) Delete d ...
- Coursera课程Python for everyone:Quiz: Object Oriented Programming
Object Oriented Programming 11 试题 1. Which came first, the instance or the class? instance class fun ...
- Coursera课程Python for everyone:Quiz: REST, JSON, and APIs
REST, JSON, and APIs 10 试题 1. Who is credited with getting the JSON movement started? Pooja Sankar M ...
- Coursera课程Python for everyone:Quiz: eXtensible Markup Language
eXtensible Markup Language 10 试题 1. What is "serialization" when we are talking about web ...
- Coursera课程Python for everyone:Quiz: Reading Web Data From Python
Reading Web Data From Python 8 试题 1. Which of the following Python data structures is most similar t ...
- Coursera课程Python for everyone:Quiz: Networks and Sockets
Networks and Sockets 10 试题 1. What do we call it when a browser uses the HTTP protocol to load a fil ...
- Coursera课程Python for everyone:Quiz: Regular Expressions
Quiz: Regular Expressions 10 试题 1. Which of the following best describes "Regular Expressions&q ...
最新文章
- k8s使用kube-router网络插件并监控流量状态
- vmware virtualization software
- 前端:前端安全编码规范
- ad域管理与维护_在NAS SMB卷上使用VisualSVN Server维护代码库
- 容器编排技术 -- Kubernetes 为 Namespace 配置CPU和内存配额
- rails_Rails应用程序必备的宝石
- android系统功耗优化(2)---Android最佳实践之性能 - 电池续航时间优化
- git管理github仓库详解
- 极简代码(三)—— 向量加法
- 企业软件是最难编写的软件
- 使用python实现深度神经网络--学习笔记
- WNM6002 N通道增强功能MOS场效应晶体管
- linux命令行里输入nyancat,好玩的Linux命令行,与彩虹猫Nyan Cat一起休息下
- wps实现冻结首行的方法
- 你在百度区块链养狗了么?
- discuz的css文件在哪里,谁能告诉我discuz模板文件在哪个文件夹下?
- QuickCHM V2.6
- Vistual Studio Community 2017 30天许可证过期
- Smartbanner: Intelligent banner design framework that strikes a balance between freedom and rules
- 运维与Python之间有着怎样的联系?
热门文章
- 银河麒麟4安装MySQL8_2020-03-24 linux 安装mysql8.0
- Java - Jackson JSON Java Parser API
- APM - Javassist 入门 生成一个简单类
- 爬虫学习笔记(九)—— Scrapy框架(四):FormRequest、日志
- Android中finish()、System.exit()、KillProcess()的区别
- php 文件夹里有多少,计算目录php中有多少个文件
- access窗体中再制作查询窗体_如何给java窗体添加下拉菜单项,以选择游戏难度为例 - 攻向前端的小白...
- idea插件Easy Code的使用
- 异常:catch下的return;
- vue 表格内容跳转页面_Vue项目实战系列文章(一)项目预热