日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

Coursera课程Python for everyone:chapter9

發(fā)布時(shí)間:2025/3/21 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Coursera课程Python for everyone:chapter9 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Chapter 9 Quiz

10?試題

1.?

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

2.?

What is a term commonly used to describe the Python dictionary feature in other programming languages?

Lambdas

Sequences

Associative arrays

Closures

3.?

What would the following Python code print out?

stuff = dict() print stuff['candy']

0

-1

The program would fail with a traceback

candy

4.?

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

5.?

(T/F) When you add items to a dictionary they remain in the order in which you added them.

False

True

6.?

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

7.?

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

8.?

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

9.?

Which method in a dictionary object gives you a list of the values in the dictionary?

items()

keys()

each()

all()

values()

10.?

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

總結(jié)

以上是生活随笔為你收集整理的Coursera课程Python for everyone:chapter9的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。