Deck 6: Dictionaries and Sets  

Full screen (f)
exit full mode
Question
Which of the following statements is false?

A) Lists and tuples are built-in xe "collection:sequence"xe "sequence collections"sequence collections.
B) Dictionaries, strings and sets are built-in xe "collection:non-sequence"xe "nonsequence collections"non-sequence collections.
C) A dictionary is an unordered collection which stores key-value pairs that map xe "immutable:keys in a dictionary"immutable keys to values, just as a conventional dictionary maps words to definitions.
D) A set is an unordered collection of unique xe "immutable:elements in a set"immutable elements.
Use Space or
up arrow
down arrow
to flip the card.
Question
Which of the following statements is false?

A) The <= operator tests whether the set to its left is an improper subset of the one to its right-that is, all the elements in the left operand are in the right operand, and the sets might be equal.
B) You also can check for an improper subset with the set method issubset.
C) You can check for an improper superset with the set method issuperset.
D) The argument to issubset or issuperset must be a set.
Question
Which of the following statements a), b) or c) is false?

A) Sets are immutable, so sets can have other sets as elements.
B) A frozenset is an xe "immutable:frozenset type"immutable set-it cannot be modified after you create it, so a set can contain frozensets as elements.
C) The built-in function frozenset creates a frozenset from any iterable.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) Assigning a value to a nonexistent key inserts the key-value pair in the dictionary.
B) String keys are case insensitive.
C) Assigning a value to a nonexistent key could be a logic error.
D) All of the above statements are true.
Question
Consider the following session: In [1]: numbers = list(range(10)) + list(range(5))
In [2]: numbers
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]
In [3]: set(numbers)
Out[3]: ???
Which of the following would be displayed where we wrote ??? in Out[3]?

A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
C) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
D) {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
Question
Which of the following statements is false?

A) The union of two sets is a set consisting of all the unique elements from both sets.
B) You can calculate the union with the | operator or with the set type's union method.
C) The operands of the binary set operators, like |, must both be any iterable.
D) The set methods may receive any iterable object as an argument.
Question
Which of the following statements a), b) or c) is false?

A) Dictionary comprehensions provide a convenient notation for quickly generating dictionaries, often by mapping one dictionary to another.
B) The following code, which has a dictionary with unique values, reverses the key-value pairs, so the values become the keys and vice versa: months = {'January': 1, 'February': 2, 'March': 3}
Months2 = {number: name for name, number in months.items()}
C) If the values in Part (b) were not unique, then the code would generate a ValueError.
D) All of the above statements are true.
Question
Which of the following statements a), b) and c) is false?

A) The following dictionary maps month-name strings to int values representing the numbers of days in the corresponding month: days_per_month = {'January': 31, 'February': 28, 'March': 31}
B) Multiple keys in a dictionary can have the same value.
C) The following for statement iterates through dictionary days_per_month's key-value pairs. Dictionary method items returns each key-value pair as a tuple, which is unpacked into the target variables month and days: for month, days in days_per_month.items():
Print(f'{month} has {days} days')
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) A dictionary associates keys with values. Each key maps to a specific value.
B) A dictionary's keys must be mutable (such as strings, numbers or tuples) and unique (that is, no duplicates).
C) Multiple keys can have the same value, such as two different inventory codes that have the same quantity in stock.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) The following code creates the dictionary roman_numerals, which maps roman numerals to their integer equivalents (the value for 'X' is intentionally wrong): roman_numerals = {'I': 1, 'II': 2, 'III': 3, 'V': 5, 'X': 100}
B) The following code gets the value associated with the key 'V' in Part (a): roman_numerals['V']
C) You can xe "dictionary built-in type:update a key's associated value"xe ""update a key's associated value in an assignment statement. The following code replaces the incorrect value associated with the key 'X' in Part (a): roman_numerals['X'] = 10
D) All of the above statements are true.
Question
Which of the following statements is false?

A) When you pass a dictionary to built-in function xe "dictionary built-in type:length"xe "dictionary built-in type:length"xe "length of a dictionary"len, the function returns the number of key-value pairs in the dictionary.
B) You can use a dictionary as a condition to determine if it's empty-a non-empty dictionary evaluates to True.
C) An empty dictionary evaluates to False.
D) Method clean deletes the dictionary's key-value pairs:
Question
Which of the following statements a), b) or c) is false?

A) The following code creates a set of strings named colors: colors = {'red', 'orange', 'yellow', 'green', 'red', 'blue'}
B) Duplicate elimination is automatic when creating a set.
C) Sets are ordered, so you can write code that depends on the order of their elements.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) The following call to dictionary method update receives a dictionary containing one key-value pair to insert or update: country_codes.update({'South Africa': 'za'})
B) Method update can convert keyword arguments into key-value pairs to insert. The following call converts the parameter name Australia into the string key 'Australia' and associates the incorrect value 'ar' with that key: country_codes.update(Australia='ar')
C) The snippet in Part (b) provided an incorrect country code ('ar') for Australia. The following code corrects this by using a keyword argument to update the value associated with 'Australia': country_codes.update(Australia='au')
D) All of the above statements are true.
Question
Which of the following statements is false?

A) A xe "built-in types:set"xe "set built-in type"set is an unordered collection of unique values.
B) Sets may contain only xe "immutable:elements in a set"immutable objects, like strings, ints, floats and tuples that contain only immutable elements.
C) Sets are iterable, so they are sequences and they support indexing and slicing with square brackets, [].
D) Dictionaries do not support slicing.
Question
Which of the following statements a), b) or c) is false?

A) The following code builds a dictionary to count the number of occurrences of each word in a string named text-the dictionary's keys will be the unique words, and its values will be integer counts of how many times each word appears in text: word_counts = {}
For word in text.split():
If word in word_counts:
Word_counts[word] += 1
Else:
Word_counts[word] = 1
B) Breaking a string into words is known as xe "tokenize a string"tokenizing the string.
C) Python automatically xe "concatenate strings separated by whitespace"concatenates strings separated by whitespace in parentheses.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) The comparison operators == and != can be used to determine whether two dictionaries have identical or different contents.
B) An equals (==) comparison evaluates to True if both dictionaries have the same key-value pairs, regardless of the order in which those pairs were added to each dictionary.
C) In the following dictionary, the keys are lists of three integer student grades and the values are strings representing the students' names. grade_book = {
'Susan': [92, 85, 100],
'Eduardo': [83, 95, 79],
'Azizi': [91, 89, 82],
'Pantipa': [97, 91, 92]
}
D) All of the above statements are true.
Question
Which of the following statements is false?

A) Dictionary methods keys and values can be used to iterate through a dictionary's keys or values, respectively.
B) Dictionary methods items, keys and values each return a view of a dictionary's data.
C) When you iterate over a view, it "sees" a copy of the dictionary's current contents.
D) You should not modify a dictionary while iterating through a view. According to the Python Standard Library documentation, either you'll get a RuntimeError or the loop might not process all of the view's values.
Question
Which of the following statements about the following code is false? word_counts = {}
For word in text.split():
If word in word_counts:
Word_counts[word] += 1
Else:
Word_counts[word] = 1

A) The expression text.split() xe "tokenize a string"tokenizes text by calling string method split, which separates the words using the method's delimiter string argument-if you do not provide an argument, split uses a space.
B) Method split returns a list of tokens (that is, the words in text).
C) The expression word_counts[word] += 1 inserts a new key-value pair in the dictionary.
D) All of the above statements are true.
Question
Which of the following statements is false?

A) You can create a dictionary by enclosing in curly braces, xe "{} for creating a dictionary"{}, a comma-separated list of key-value pairs, each of the form key: value.
B) You can create an empty dictionary with {}.
C) The following statement creates a dictionary with the country-name keys 'Finland', 'South Africa' and 'Nepal' and their corresponding Internet country code values 'fi', 'za' and 'np': country_codes = {'Finland', 'fi', 'South Africa', 'za',
'Nepal', 'np'}
D) When you output a dictionary, its comma-separated list of key-value pairs is always enclosed in curly braces.
Question
Which of the following statements is false?

A) You can determine the number of items in a set with the built-in len function.
B) You can check whether a set contains a particular value using the xe "in operator"in and xe "not in operator"not in operators.
C) Sets are not iterable, so you cannot process each set element with a for loop.
D) Sets are unordered, so there's no significance to the iteration order.
Question
Which of the following statements about FuncAnimation is false?

A) FuncAnimation has two required arguments-the Figure object in which to display the animation, and a function to call once per animation frame.
B) The FuncAnimation argument interval is the number of milliseconds between animation frames (the default is 200).
C) The FuncAnimation argument fargs (short for "function arguments") is a tuple of other arguments to pass to the function you specify in xe "animation module (Matplotlib):FuncAnimation function"xe "FuncAnimation (Matplotlib animation module)"FuncAnimation's second argument.
D) All of the above statements are true.
Question
What values are actually displayed where we've inserted ??? in Out[1] and Out[2]: In [1]: {1, 3, 5}.isdisjoint({2, 4, 6})
Out[1]: ???
In [2]: {1, 3, 5}.isdisjoint({4, 6, 1})
Out[2]: ???

A) False, False
B) False, True
C) True, False
D) True, True
Question
Which of the following statements a), b) or c) is false?

A) You can calculate the intersection with the & operator or with the set type's intersection method.
B) The difference between two sets is a set consisting of the elements in the left operand that are not in the right operand.
C) You can calculate the difference with the - operator or with the a set's difference method.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) If the random module's randrange function indeed produces integers at random, then every number in the specified range has an equal xe "probability"probability (or likelihood) of being chosen each time the function is called.
B) For six-sided die rolls, each value 1 through 6 should occur about one-sixth of the time, so the probability of any one of these values occurring is 1/6th or about 16.667%.
C) The more die rolls we attempt, the closer each die value's percentage of the total rolls gets to 16.667%. This is a manifestation of Moore's Law.
D) All of the above statements are true.
Question
Which of the following statements is false?

A) Set method add inserts its argument if the argument is not already in the set; otherwise, the set remains unchanged.
B) Set method remove removes its argument from a set. A KeyError occurs if the value is not in the set.
C) Method discard also removes its argument from a set but does not cause an exception if the value is not in the set.
D) You can remove the first element of a set with pop.
Question
Which of the following statements a), b) or c) is false?

A) Like operator |, union augmented assignment |= performs a set union operation, but |= doesn't modify its left operand.
B) The set type's update method performs a union operation modifying the set on which it's called-the argument can be any iterable.
C) Other mutable set methods are xe "intersection augmented assignment"intersection augmented assignment xe "&= set intersection augmented assignment"&=, xe "difference augmented assignment (sets)"difference augmented assignment xe "-= set difference augmented assignment"-= and xe "symmetric difference augmented assignment"symmetric difference augmented assignment xe "^= set symmetric difference augmented assignment"^=. Their corresponding methods with iterable arguments are xe "set built-in type:intersection_update"xe "intersection_update method of set"intersection_update, xe "set built-in type:difference_update"xe "difference_update method of set"difference_update and xe "set built-in type:symmetric_difference_update"xe "symmetric_difference_update method of set"symmetric_difference_update.
D) All of the above statements are true.
Question
Which of the following statements a), b) or c) is false?

A) For each animation frame, a Matplotlib FuncAnimation calls a function that you define to specify how to change the plot.
B) Displaying animation frames to the screen is relatively fastxe "input-output bound" compared to the die rolls, which occur at the computer's CPU speeds.
C) If we roll only one die per animation frame, we won't be able to run a large number of rolls in a reasonable amount of time. You can increase the execution speed of the simulation by rolling the die more times per animation frame.
D) All of the above statements are true.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/27
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Dictionaries and Sets  
1
Which of the following statements is false?

A) Lists and tuples are built-in xe "collection:sequence"xe "sequence collections"sequence collections.
B) Dictionaries, strings and sets are built-in xe "collection:non-sequence"xe "nonsequence collections"non-sequence collections.
C) A dictionary is an unordered collection which stores key-value pairs that map xe "immutable:keys in a dictionary"immutable keys to values, just as a conventional dictionary maps words to definitions.
D) A set is an unordered collection of unique xe "immutable:elements in a set"immutable elements.
B
2
Which of the following statements is false?

A) The <= operator tests whether the set to its left is an improper subset of the one to its right-that is, all the elements in the left operand are in the right operand, and the sets might be equal.
B) You also can check for an improper subset with the set method issubset.
C) You can check for an improper superset with the set method issuperset.
D) The argument to issubset or issuperset must be a set.
D
3
Which of the following statements a), b) or c) is false?

A) Sets are immutable, so sets can have other sets as elements.
B) A frozenset is an xe "immutable:frozenset type"immutable set-it cannot be modified after you create it, so a set can contain frozensets as elements.
C) The built-in function frozenset creates a frozenset from any iterable.
D) All of the above statements are true.
A
4
Which of the following statements a), b) or c) is false?

A) Assigning a value to a nonexistent key inserts the key-value pair in the dictionary.
B) String keys are case insensitive.
C) Assigning a value to a nonexistent key could be a logic error.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
5
Consider the following session: In [1]: numbers = list(range(10)) + list(range(5))
In [2]: numbers
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]
In [3]: set(numbers)
Out[3]: ???
Which of the following would be displayed where we wrote ??? in Out[3]?

A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
C) {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
D) {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following statements is false?

A) The union of two sets is a set consisting of all the unique elements from both sets.
B) You can calculate the union with the | operator or with the set type's union method.
C) The operands of the binary set operators, like |, must both be any iterable.
D) The set methods may receive any iterable object as an argument.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following statements a), b) or c) is false?

A) Dictionary comprehensions provide a convenient notation for quickly generating dictionaries, often by mapping one dictionary to another.
B) The following code, which has a dictionary with unique values, reverses the key-value pairs, so the values become the keys and vice versa: months = {'January': 1, 'February': 2, 'March': 3}
Months2 = {number: name for name, number in months.items()}
C) If the values in Part (b) were not unique, then the code would generate a ValueError.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements a), b) and c) is false?

A) The following dictionary maps month-name strings to int values representing the numbers of days in the corresponding month: days_per_month = {'January': 31, 'February': 28, 'March': 31}
B) Multiple keys in a dictionary can have the same value.
C) The following for statement iterates through dictionary days_per_month's key-value pairs. Dictionary method items returns each key-value pair as a tuple, which is unpacked into the target variables month and days: for month, days in days_per_month.items():
Print(f'{month} has {days} days')
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following statements a), b) or c) is false?

A) A dictionary associates keys with values. Each key maps to a specific value.
B) A dictionary's keys must be mutable (such as strings, numbers or tuples) and unique (that is, no duplicates).
C) Multiple keys can have the same value, such as two different inventory codes that have the same quantity in stock.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following statements a), b) or c) is false?

A) The following code creates the dictionary roman_numerals, which maps roman numerals to their integer equivalents (the value for 'X' is intentionally wrong): roman_numerals = {'I': 1, 'II': 2, 'III': 3, 'V': 5, 'X': 100}
B) The following code gets the value associated with the key 'V' in Part (a): roman_numerals['V']
C) You can xe "dictionary built-in type:update a key's associated value"xe ""update a key's associated value in an assignment statement. The following code replaces the incorrect value associated with the key 'X' in Part (a): roman_numerals['X'] = 10
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following statements is false?

A) When you pass a dictionary to built-in function xe "dictionary built-in type:length"xe "dictionary built-in type:length"xe "length of a dictionary"len, the function returns the number of key-value pairs in the dictionary.
B) You can use a dictionary as a condition to determine if it's empty-a non-empty dictionary evaluates to True.
C) An empty dictionary evaluates to False.
D) Method clean deletes the dictionary's key-value pairs:
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following statements a), b) or c) is false?

A) The following code creates a set of strings named colors: colors = {'red', 'orange', 'yellow', 'green', 'red', 'blue'}
B) Duplicate elimination is automatic when creating a set.
C) Sets are ordered, so you can write code that depends on the order of their elements.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following statements a), b) or c) is false?

A) The following call to dictionary method update receives a dictionary containing one key-value pair to insert or update: country_codes.update({'South Africa': 'za'})
B) Method update can convert keyword arguments into key-value pairs to insert. The following call converts the parameter name Australia into the string key 'Australia' and associates the incorrect value 'ar' with that key: country_codes.update(Australia='ar')
C) The snippet in Part (b) provided an incorrect country code ('ar') for Australia. The following code corrects this by using a keyword argument to update the value associated with 'Australia': country_codes.update(Australia='au')
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following statements is false?

A) A xe "built-in types:set"xe "set built-in type"set is an unordered collection of unique values.
B) Sets may contain only xe "immutable:elements in a set"immutable objects, like strings, ints, floats and tuples that contain only immutable elements.
C) Sets are iterable, so they are sequences and they support indexing and slicing with square brackets, [].
D) Dictionaries do not support slicing.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following statements a), b) or c) is false?

A) The following code builds a dictionary to count the number of occurrences of each word in a string named text-the dictionary's keys will be the unique words, and its values will be integer counts of how many times each word appears in text: word_counts = {}
For word in text.split():
If word in word_counts:
Word_counts[word] += 1
Else:
Word_counts[word] = 1
B) Breaking a string into words is known as xe "tokenize a string"tokenizing the string.
C) Python automatically xe "concatenate strings separated by whitespace"concatenates strings separated by whitespace in parentheses.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following statements a), b) or c) is false?

A) The comparison operators == and != can be used to determine whether two dictionaries have identical or different contents.
B) An equals (==) comparison evaluates to True if both dictionaries have the same key-value pairs, regardless of the order in which those pairs were added to each dictionary.
C) In the following dictionary, the keys are lists of three integer student grades and the values are strings representing the students' names. grade_book = {
'Susan': [92, 85, 100],
'Eduardo': [83, 95, 79],
'Azizi': [91, 89, 82],
'Pantipa': [97, 91, 92]
}
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following statements is false?

A) Dictionary methods keys and values can be used to iterate through a dictionary's keys or values, respectively.
B) Dictionary methods items, keys and values each return a view of a dictionary's data.
C) When you iterate over a view, it "sees" a copy of the dictionary's current contents.
D) You should not modify a dictionary while iterating through a view. According to the Python Standard Library documentation, either you'll get a RuntimeError or the loop might not process all of the view's values.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements about the following code is false? word_counts = {}
For word in text.split():
If word in word_counts:
Word_counts[word] += 1
Else:
Word_counts[word] = 1

A) The expression text.split() xe "tokenize a string"tokenizes text by calling string method split, which separates the words using the method's delimiter string argument-if you do not provide an argument, split uses a space.
B) Method split returns a list of tokens (that is, the words in text).
C) The expression word_counts[word] += 1 inserts a new key-value pair in the dictionary.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following statements is false?

A) You can create a dictionary by enclosing in curly braces, xe "{} for creating a dictionary"{}, a comma-separated list of key-value pairs, each of the form key: value.
B) You can create an empty dictionary with {}.
C) The following statement creates a dictionary with the country-name keys 'Finland', 'South Africa' and 'Nepal' and their corresponding Internet country code values 'fi', 'za' and 'np': country_codes = {'Finland', 'fi', 'South Africa', 'za',
'Nepal', 'np'}
D) When you output a dictionary, its comma-separated list of key-value pairs is always enclosed in curly braces.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following statements is false?

A) You can determine the number of items in a set with the built-in len function.
B) You can check whether a set contains a particular value using the xe "in operator"in and xe "not in operator"not in operators.
C) Sets are not iterable, so you cannot process each set element with a for loop.
D) Sets are unordered, so there's no significance to the iteration order.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following statements about FuncAnimation is false?

A) FuncAnimation has two required arguments-the Figure object in which to display the animation, and a function to call once per animation frame.
B) The FuncAnimation argument interval is the number of milliseconds between animation frames (the default is 200).
C) The FuncAnimation argument fargs (short for "function arguments") is a tuple of other arguments to pass to the function you specify in xe "animation module (Matplotlib):FuncAnimation function"xe "FuncAnimation (Matplotlib animation module)"FuncAnimation's second argument.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
22
What values are actually displayed where we've inserted ??? in Out[1] and Out[2]: In [1]: {1, 3, 5}.isdisjoint({2, 4, 6})
Out[1]: ???
In [2]: {1, 3, 5}.isdisjoint({4, 6, 1})
Out[2]: ???

A) False, False
B) False, True
C) True, False
D) True, True
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following statements a), b) or c) is false?

A) You can calculate the intersection with the & operator or with the set type's intersection method.
B) The difference between two sets is a set consisting of the elements in the left operand that are not in the right operand.
C) You can calculate the difference with the - operator or with the a set's difference method.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following statements a), b) or c) is false?

A) If the random module's randrange function indeed produces integers at random, then every number in the specified range has an equal xe "probability"probability (or likelihood) of being chosen each time the function is called.
B) For six-sided die rolls, each value 1 through 6 should occur about one-sixth of the time, so the probability of any one of these values occurring is 1/6th or about 16.667%.
C) The more die rolls we attempt, the closer each die value's percentage of the total rolls gets to 16.667%. This is a manifestation of Moore's Law.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following statements is false?

A) Set method add inserts its argument if the argument is not already in the set; otherwise, the set remains unchanged.
B) Set method remove removes its argument from a set. A KeyError occurs if the value is not in the set.
C) Method discard also removes its argument from a set but does not cause an exception if the value is not in the set.
D) You can remove the first element of a set with pop.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following statements a), b) or c) is false?

A) Like operator |, union augmented assignment |= performs a set union operation, but |= doesn't modify its left operand.
B) The set type's update method performs a union operation modifying the set on which it's called-the argument can be any iterable.
C) Other mutable set methods are xe "intersection augmented assignment"intersection augmented assignment xe "&= set intersection augmented assignment"&=, xe "difference augmented assignment (sets)"difference augmented assignment xe "-= set difference augmented assignment"-= and xe "symmetric difference augmented assignment"symmetric difference augmented assignment xe "^= set symmetric difference augmented assignment"^=. Their corresponding methods with iterable arguments are xe "set built-in type:intersection_update"xe "intersection_update method of set"intersection_update, xe "set built-in type:difference_update"xe "difference_update method of set"difference_update and xe "set built-in type:symmetric_difference_update"xe "symmetric_difference_update method of set"symmetric_difference_update.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following statements a), b) or c) is false?

A) For each animation frame, a Matplotlib FuncAnimation calls a function that you define to specify how to change the plot.
B) Displaying animation frames to the screen is relatively fastxe "input-output bound" compared to the die rolls, which occur at the computer's CPU speeds.
C) If we roll only one die per animation frame, we won't be able to run a large number of rolls in a reasonable amount of time. You can increase the execution speed of the simulation by rolling the die more times per animation frame.
D) All of the above statements are true.
Unlock Deck
Unlock for access to all 27 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 27 flashcards in this deck.