Starting Out with Python, 3e Ch 9
This operator can be used to find the intersection of two sets. a. I b. & c. - d. ^
&
This operator can be used to find the difference of two sets. a. I b. & c. - d. ^
-
A list can be a dictionary key. T or F
False
The dictionary method popitem does not raise an exception if it is called on an empty dictionary. T or F
False
The following statement creates an empty set: myset = ( ) T or F
False
The keys in a dictionary must be mutable objects. T or F
False
You can store duplicate elements in a set. T or F
False
This operator can be used to find the union of two sets. a. I b. & c. - d. ^
I
A tuple can be a dictionary key. T or F
True
Dictionaries are not sequences. T or F
True
Sets store their elements in an unordered fashion. T or F
True
The following statement creates an empty dictionary: mydct = { } T or F
True
The remove method raises an exception if the specified element is not found in the set. T or F
True
This operator can be used to find the symmetric difference of two sets. a. I b. & c. - d. ^
^
You can add one element to a set with this method. a. append b. add c. update d. merge
add
This set method removes an element but does not raise an exception if the element is not found. a. remove b. discard c. delete d. erase
discard
The ____ dictionary method returns the value associated with a specified key. If the key is not found, it returns a default value. a. pop( ) b. key( ) c. value( ) d. get( )
get( )
You can use the ____ operator to determine whether a key exists in a dictionary. a. & b. in c. ^ d. ?
in
The ____ method returns all of a dictionary's keys and their associated values as a sequence of tuples. a. keys_values( ) b. values( ) c. items ( ) d. get( )
items ( )
The ____ function returns the number of elements in a dictionary: a. size( ) b. len( ) c. elements( ) d. count( )
len( )
The following function returns the number of elements in a set: a. size( ) b. len( ) c. elements( ) d. count( )
len( )
The ____ method returns the value associated with a specified key and removes that key-value pair from the dictionary . a. pop( ) b. random( ) c. popitem( ) d. rand_pop( )
pop( )
The ____ method returns a randomly selected key-value pair from a dictionary. a. pop( ) b. random( ) c. popitem( ) d. rand pop( )
popitem( )
This set method removes an element and raises an exception if the element is not found. a. remove b. discard c. delete d. erase
remove
You use ____ to delete an element from a dictionary. a. the remove method b. the erase method c. the delete method d. the del statement
the del statement
You can add a group of elements to a set with this method. a. append b. add c. update d. merge
update
You can use ____ to create an empty dictionary. a. { } b. ( ) c. [ ] d. empty( )
{ }