Filters
Question type

Study Flashcards

The elements in a dictionary are not stored in a specific order. Therefore a dictionary is not a(n) _______________.

Correct Answer

verifed

verified

The built-in function _______________ returns the number of items in a set.

Correct Answer

verifed

verified

The set remove and discard methods behave differently only when a specified item is not found in the set.

Correct Answer

verifed

verified

In order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the _____ operator.


A) included
B) of
C) in
D) not in

Correct Answer

verifed

verified

Which method would you use to returns all the elements in the dictionary as a list of tuples?


A) list
B) items
C) pop
D) keys

Correct Answer

verifed

verified

What is the correct structure for creating a dictionary of month names to be accessed by month numbers?


A) { 1 ; 'January', 2 ; 'February', 3 ; 'March' }
B) { 1 : 'January', 2 : 'February', 3 : 'March' }
C) [ 1 : 'January', 2 : 'February', 3 : 'March' ]
D) { 1, 2, 3 : 'January', 'February', 'March' }

Correct Answer

verifed

verified

What method can be used to add a group of elements to a set?


A) add
B) addgroup
C) update
D) Elements must be added one at a time.

Correct Answer

verifed

verified

The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2.

Correct Answer

verifed

verified

The _______________ of two sets is a set that contains all the elements of both sets.

Correct Answer

verifed

verified

To determine whether a key is not included in a dictionary, or an element is not included in a set, you can use the _______________ operator.

Correct Answer

verifed

verified

You created the following dictionary relationships = {'Jimmy':'brother'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception? Relationships['jimmy']


A) String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.
B) You used the wrong syntax for creating the dictionary.
C) You should have used the code relationships['brother'].
D) There is a bug in Python.

Correct Answer

verifed

verified

What is the value of the variable phones after the execution of the following code? Phones = {'John': '5555555', 'Julie' : '7777777'} Phones['John'] = '1234567'


A) {'John': '5555555', 'Julie' : '7777777'}
B) {'John': '1234567', 'Julie' : '7777777'}
C) {'John': '1234567' }
D) invalid code

Correct Answer

verifed

verified

The issubset method can be used to determine whether set1 is a subset of set2.

Correct Answer

verifed

verified

The index of the first key-value pair in a dictionary is 0.

Correct Answer

verifed

verified

The _______________ method returns a value associated with a specified key and if found, removes that key-value pair from the dictionary.

Correct Answer

verifed

verified

Showing 21 - 35 of 35

Related Exams

Show Answer