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

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

生活随笔

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

python

Coursera课程Python for everyone:chapter10

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

Chapter 10 Quiz

10?試題

1.?

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

2.?

Which of the following methods work both in Python lists and Python tuples?

pop()

index()

sort()

reverse()

append()

3.?

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

4.?

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

5.?

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)

6.?

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

7.?

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)

8.?

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)

9.?

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

10.?

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

總結(jié)

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

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