0% found this document useful (0 votes)
1K views5 pages

Chapter 8 Quiz - Coursera

This document contains a 10 question quiz about Python lists and loops from an online Coursera course. The questions cover topics like the difference between collection and normal variables, using for/in loops to iterate through lists, accessing and modifying list elements, built-in functions like len() and range(), list slicing, and list methods like append(), sort(), and pop().

Uploaded by

Shaamim U Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views5 pages

Chapter 8 Quiz - Coursera

This document contains a 10 question quiz about Python lists and loops from an online Coursera course. The questions cover topics like the difference between collection and normal variables, using for/in loops to iterate through lists, accessing and modifying list elements, built-in functions like len() and range(), list slicing, and list methods like append(), sort(), and pop().

Uploaded by

Shaamim U Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1/8/2016

Chapter8Quiz|Coursera

Chapter 8 Quiz
10questions

1.
How are "collection" variables different from normal variables?
Collection variables can only store a single value
Collection variables pull multiple network documents together
Collection variables can store multiple values in a single
variable
Collection variables merge streams of output into a single
stream

2.
What are the Python keywords used to construct a loop to iterate through
a list?
try / except
for / in
foreach / in
def / return

3.
For the following list, how would you print out 'Sally'?
https://www.coursera.org/learn/pythondata/exam/xPuAG/chapter8quiz

1/5

1/8/2016

Chapter8Quiz|Coursera

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

print friends['Sally']
print friends[2:1]
print friends[2]
print friends[3]

4.
What would the following Python code print out?
fruit='Banana'
fruit[0]='b'
printfruit

banana
B
Nothing would print - the program fails with a traceback
Banana
[0]
b

5.
Which of the following Python statements would print out the length of a
list stored in the variable data?
print len(data)
print data.length()
print strlen(data)
https://www.coursera.org/learn/pythondata/exam/xPuAG/chapter8quiz

2/5

1/8/2016

Chapter8Quiz|Coursera

print data.Len
print data.length
print length(data)

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 characters
A list of words
A list of integers

7.
What does the following Python code print out?
a=[1,2,3]
b=[4,5,6]
c=a+b
printlen(c)

[4, 5, 6]
[1, 2, 3, 4, 5, 6]
15
21
[1, 2, 3]
https://www.coursera.org/learn/pythondata/exam/xPuAG/chapter8quiz

3/5

1/8/2016

Chapter8Quiz|Coursera

8.
Which of the following slicing operations will produce the list [12, 3]?
t=[9,41,12,3,74,15]

t[2:4]
t[:]
t[12:3]
t[2:2]
t[1:3]

9.
What list method adds a new item to the end of an existing list?
pop()
add()
push()
forward()
index()
append()

10.
What will the following Python code print out?

https://www.coursera.org/learn/pythondata/exam/xPuAG/chapter8quiz

4/5

1/8/2016

Chapter8Quiz|Coursera

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

Glenn
friends
Joseph
Sally

Submit Quiz

https://www.coursera.org/learn/pythondata/exam/xPuAG/chapter8quiz

5/5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy