Tuesday, July 24, 2018

Python Data Structures - Chapter 9 Quiz

Question 2
1
point

2. Question 2

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

3. Question 3

What would the following Python code print out?
1
2
stuff = dict()
print(stuff['candy'])
Question 4
1
point

4. Question 4

What would the following Python code print out?
1
2
stuff = dict()
print(stuff.get('candy',-1))
Question 5
1
point

5. Question 5

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

6. Question 6

What is a common use of Python dictionaries in a program?
Question 7
1
point

7. Question 7

Which of the following lines of Python is equivalent to the following sequence of statements assuming that counts is a dictionary?
1
2
3
4
if key in counts:
counts[key] = counts[key] + 1
else:
counts[key] = 1
Question 8
1
point

8. Question 8

In the following Python, what does the for loop iterate through?
1
2
3
4
x = dict()
...
for y in x :
...
Question 9
1
point

9. Question 9

Which method in a dictionary object gives you a list of the values in the dictionary?
Question 10
1
point

10. Question 10

What is the purpose of the second parameter of the get() method for Python dictionaries?

2 comments: