Dictionaries and Sets Flashcards
(Fill-In) _____ can be thought of as unordered collections in which each value is accessed through its corresponding key.
Dictionaries
(True/False) Dictionaries may contain duplicate keys.
False. Dictionary keys must be unique. However, multiple keys may have the same value.
(Fill-In) Dictionary method _____ returns each key–value pair as a tuple.
items
(True/False) Assigning to a nonexistent dictionary key causes an exception.
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.
(Fill-In) What does an expression of the following form do when the key is in the dictionary?
dictionaryName[key] = value
Answer: It updates the value associated with the key, replacing the original value.
(Fill-In) Dictionary method ____ returns an unordered list of the dictionary’s keys.
keys.
(True/False) A view has its own copy of the corresponding data from the dictionary.
False. A view does not have its own copy of the corresponding data from the dictionary. As the dictionary changes, each view updates dynamically.
(True/False) The == comparison evaluates to True only if both dictionaries have the
same key–value pairs in the same order.
False. The == comparison evaluates to True if both dictionaries have the same
key–value pairs, regardless of their order.
(Fill-In) String method ______ tokenizes a string using the delimiter provided in the method’s string argument.
split.
(True/False) Sets are collections of unique mutable and immutable objects.
False. Sets are collections of unique immutable objects
(Fill-In) You can create a set from another collection of values by using the built-in ______ function
set.
(True/False) Sets may be compared with only the == and != comparison operators.
False. All the comparison operators may be used to compare sets.
(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.
proper.
(Fill-In) Two sets are _____ if the sets do not have any common elements.
disjoint.
(True/False) Set method pop returns the first element added to the set.
False. Set method pop returns an arbitrary set element.
(Fill-In) Set method _____ performs a union operation, modifying the set on which it’s called.
update.
(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 __________.
the law of large numbers.
(Fill-In) A(n) ______ specifies everything that should change during one plot update. Stringing together many of these over time creates the animation effect.
animation frame.
(True/False) Generally, displaying fewer frames-per-second yields smoother animation.
False. Generally, displaying more frames-per-second yields smoother animation.
(True/False) The actual number of frames-per-second is affected only by the millisecond interval between animation frames.
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.
(Fill-In) The Matplotlib ______ module’s _____ function dynamically updates
a visualization.
animation, FuncAnimation.
(Fill-In) FuncAnimation’s _____ keyword argument enables you to pass custom arguments to the function that’s called once per animation frame.
fargs.