Coursera课程Python for everyone:chapter10
Chapter 10 Quiz
10 试题
What is the difference between a Python tuple and Python list?
Lists are mutable and tuples are not mutable
Lists maintain the order of the items and tuples do not maintain order
Tuples can be expanded after they are created and lists cannot
Lists are indexed by integers and tuples are indexed by strings
Which of the following methods work both in Python lists and Python tuples?
pop()
index()
sort()
reverse()
append()
What will end up in the variable y after this code is executed?
x , y = 3, 4
A two item tuple
3
4
A dictionary with the key 3 mapped to the value 4
A two item list
In the following Python code, what will end up in the variable y?
x = { 'chuck' : 1 , 'fred' : 42, 'jan': 100} y = x.items()
A list of strings
A list of tuples
A list of integers
A tuple with three integers
Which of the following tuples is greater than x in the following Python sequence?
x = (5, 1, 3) if ??? > x :...
(6, 0, 0)
(5, 0, 300)
(0, 1000, 2000)
(4, 100, 200)
What does the following Python code accomplish, assuming the c is a non-empty dictionary?
tmp = list() for k, v in c.items() :tmp.append( (v, k) )
It computes the largest of all of the values in the dictionary
It computes the average of all of the values in the dictionary
It sorts the dictionary based on its key values
It creates a list of tuples where each tuple is a value, key pair
If the variable data is a Python list, how do we sort it in reverse order?
data.sort(reverse=True)
data.sort.reverse()
data = sortrev(data)
data = data.sort(-1)
Using the following tuple, how would you print 'Wed'?
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
print days[2]
print days{2}
print days(2)
print days[1]
print days.get(1,-1)
In the following Python loop, why are there two iteration variables (k and v)?
c = {'a':10, 'b':1, 'c':22} for k, v in c.items() :...
Because the items() method in dictionaries returns a list of tuples
Because for each item we want the previous and current key
Because there are two items in the dictionary
Because the keys for the dictionary are strings
Given that Python lists and Python tuples are quite similar - when might you prefer to use a tuple over a list?
For a list of items you intend to sort in place
For a list of items that want to use strings as key values instead of integers
For a list of items that will be extended as new items are found
For a temporary variable that you will use and discard without modifying
Coursera课程Python for everyone:chapter10相关推荐
- 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 ...
最新文章
- maven的setting.xml文件配置信息【仅仅更改了一处】
- 使用Ptrace跟踪进程收到的异常信号(信号SIGTRAP是通过traceme后wait得到的)
- c++精确到小数点后两位_高考试卷的小数点是怎么算入总分的?
- Vue指令之v-model和双向数据绑定
- 【2019暑假刷题笔记-树的遍历】总结
- spring boot使用外置tomcat部署需要排除的依赖
- java tostring 库_java重寫toString()方法
- VS2010关于更改管理帮助设置的路径的解决方案
- python文件路径改了需要重新配置环境吗_python自学环境配置
- Python基础-程序控制结构
- HBase完全分布式集群部署
- 【转】扫盲 同步利器、分布式网盘--BT Sync
- 使用奇妙清单:轻松搞定家庭计划事项同步管理
- 刀剑神域:突破界限I
- 主成分分析结果成分不显著_主成分分析结果
- 【华人学者风采】丛京生 加州大学洛杉矶分校
- 免登录采集淘宝商品详情的方法
- 91文件夹操作——创建和删除多级目录
- 简历之精通 熟练 掌握 熟悉 了解
- 更新hdf之后无法找到接口映射
热门文章
- 美团点评业务风控系统构建经验
- 教程 | 理解和实现自然语言处理终极指南(附Python代码)
- 国家卫计委倡导健康生活理念:每天发呆5分钟
- RocketMQ-初体验RocketMQ(04)_使用RocketMQ Console源码搭建RocketMQ Console与基本使用
- ORACLE-WITH 子句详解
- java抢答器代码_java竞争抢答器
- Android之----Log详解(Log.v,Log.d,Log.i,Log.w,Log.e)
- 双代号网络图节点编号原则_一表多图(表格/横道图/网络图)让计划编制效率提高10倍...
- numpy.lib.stride_tricks.as_strided() 高效切分数组
- 老旧计算机升级云桌面,哇哦!PC机房轻松升级云课堂 ,PC利旧方案看我的!