Filters
Question type

Study Flashcards

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

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

Which would you use to get the number of elements in a dictionary?


A) size
B) length
C) len
D) sizeof

Correct Answer

verifed

verified

A(n)__________ is an object that holds multiple unique items of data in an unordered manner.

Correct Answer

verifed

verified

To write an object to a file,you use the __________ function of the __________ module.

Correct Answer

verifed

verified

What does the get method do if the specified key is not found in the dictionary?


A) It throws an exception.
B) It does nothing.
C) It returns a default value.
D) You cannot use the get method to specify a key.

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

Sets are created using curly braces { }.

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) in
C) isnotin
D) isin

Correct Answer

verifed

verified

The union of two sets is a set that contains only the elements that appear in both sets.

Correct Answer

verifed

verified

False

Which method would you use to get the value associated with a specific key and remove that key-value pair from the dictionary?


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

Correct Answer

verifed

verified

What will be the result of the following code? Ages = {'Aaron' : 6,'Kelly' : 3,'Abigail' : 1 } Value = ages['Brianna']


A) False
B) -1
C) 0
D) KeyError

Correct Answer

verifed

verified

What is the number of the first index in a dictionary?


A) 0
B) 1
C) the size of the dictionary minus one
D) Dictionaries are not indexed by number.

Correct Answer

verifed

verified

What is the value of the variable phones after the following code executes? Phones = {'John' : '5555555','Julie' : '5557777'} Phones['John'] = 5556666'


A) {'John' : '5555555', 'Julie' : '5557777'}
B) {'John' : '5556666', 'Julie' : '5557777'}
C) {'John' : '5556666'}
D) This code is invalid.

Correct Answer

verifed

verified

Sets are immutable.

Correct Answer

verifed

verified

The __________ method returns all of a dictionary's keys as a dictionary view.

Correct Answer

verifed

verified

Which would you use to delete an existing key-value pair from a dictionary?


A) del
B) remove
C) delete
D) unpair

Correct Answer

verifed

verified

A dictionary can include the same value several times but cannot include the same key several times.

Correct Answer

verifed

verified

True

What is the correct structure to create a dictionary of months where each month will be accessed by its month number (for example,January is month 1,April is month 4) ?


A) { 1 ; 'January', 2 ; 'February', ... 12 ; 'December'}
B) { 1 : 'January', 2 : 'February', ... 12 : 'December' }
C) [ '1' : 'January', '2' : 'February', ... '12' : 'December' ]
D) { 1, 2,... 12 : 'January', 'February',... 'December' }

Correct Answer

verifed

verified

B

You would typically use a for loop to iterate over the elements in a set.

Correct Answer

verifed

verified

Showing 1 - 20 of 39

Related Exams

Show Answer