Dictionaries and Sets Flashcards

1
Q

(Fill-In) _____ can be thought of as unordered collections in which each value is accessed through its corresponding key.

A

Dictionaries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

(True/False) Dictionaries may contain duplicate keys.

A

False. Dictionary keys must be unique. However, multiple keys may have the same value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

(Fill-In) Dictionary method _____ returns each key–value pair as a tuple.

A

items

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

(True/False) Assigning to a nonexistent dictionary key causes an exception.

A

False. Assigning to a nonexistent key inserts a new key–value pair. This may be what you intend, or it could be a logic error if you incorrectly specify the key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

(Fill-In) What does an expression of the following form do when the key is in the dictionary?

dictionaryName[key] = value

A

Answer: It updates the value associated with the key, replacing the original value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

(Fill-In) Dictionary method ____ returns an unordered list of the dictionary’s keys.

A

keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

(True/False) A view has its own copy of the corresponding data from the dictionary.

A

False. A view does not have its own copy of the corresponding data from the dictionary. As the dictionary changes, each view updates dynamically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

(True/False) The == comparison evaluates to True only if both dictionaries have the
same key–value pairs in the same order.

A

False. The == comparison evaluates to True if both dictionaries have the same
key–value pairs, regardless of their order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

(Fill-In) String method ______ tokenizes a string using the delimiter provided in the method’s string argument.

A

split.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

(True/False) Sets are collections of unique mutable and immutable objects.

A

False. Sets are collections of unique immutable objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

(Fill-In) You can create a set from another collection of values by using the built-in ______ function

A

set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

(True/False) Sets may be compared with only the == and != comparison operators.

A

False. All the comparison operators may be used to compare sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

(Fill-In) A subset is a(n) _____ subset of another set if all the subset’s elements are in the other set and the other set has more elements.

A

proper.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

(Fill-In) Two sets are _____ if the sets do not have any common elements.

A

disjoint.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

(True/False) Set method pop returns the first element added to the set.

A

False. Set method pop returns an arbitrary set element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

(Fill-In) Set method _____ performs a union operation, modifying the set on which it’s called.

A

update.

17
Q

(Fill-In) As we toss a coin an increasing number of times, we expect the percentages of heads and tails to become closer to 50% each. This is a manifestation of __________.

A

the law of large numbers.

18
Q

(Fill-In) A(n) ______ specifies everything that should change during one plot update. Stringing together many of these over time creates the animation effect.

A

animation frame.

19
Q

(True/False) Generally, displaying fewer frames-per-second yields smoother animation.

A

False. Generally, displaying more frames-per-second yields smoother animation.

20
Q

(True/False) The actual number of frames-per-second is affected only by the millisecond interval between animation frames.

A

False. The actual number of frames-per-second also can be affected by the amount of work performed in each frame and the speed of your computer’s processor.

21
Q

(Fill-In) The Matplotlib ______ module’s _____ function dynamically updates
a visualization.

A

animation, FuncAnimation.

22
Q

(Fill-In) FuncAnimation’s _____ keyword argument enables you to pass custom arguments to the function that’s called once per animation frame.

A

fargs.