Coursera课程Python for everyone:chapter8

Chapter 8 Quiz

10 试题

1. 

How are "collection" variables different from normal variables?

Collection variables pull multiple network documents together

Collection variables merge streams of output into a single stream

Collection variables can store multiple values in a single variable

Collection variables can only store a single value

2. 

What are the Python keywords used to construct a loop to iterate through a list?

def / return

foreach / in

try / except

for / in

3. 

For the following list, how would you print out 'Sally'?

friends = [ 'Joseph', 'Glenn', 'Sally' ]

print friends[2:1]

print friends['Sally']

print friends[3]

print friends[2]

4. 

What would the following Python code print out?

fruit = 'Banana'
fruit[0] = 'b'
print fruit

b

banana

B

Nothing would print - the program fails with a traceback

[0]

Banana

5. 

Which of the following Python statements would print out the length of a list stored in the variabledata?

print data.length()

print len(data)

print strlen(data)

print length(data)

print data.length

print data.Len

6. 

What type of data is produced when you call the range() function?

x = range(5)

A boolean (true/false) value

A string

A list of integers

A list of characters

A list of words

7. 

What does the following Python code print out?

a = [1, 2, 3]
b = [4, 5, 6]
c = a + b
print len(c)

[1, 2, 3]

15

21

[1, 2, 3, 4, 5, 6]

[4, 5, 6]

6

8. 

Which of the following slicing operations will produce the list [12, 3]?

t = [9, 41, 12, 3, 74, 15]

t[:]

t[12:3]

t[2:2]

t[1:3]

t[2:4]

9. 

What list method adds a new item to the end of an existing list?

pop()

index()

push()

add()

append()

forward()

10. 

What will the following Python code print out?

friends = [ 'Joseph', 'Glenn', 'Sally' ]
friends.sort()
print friends[0]

Joseph

Sally

Glenn

friends

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值