Deck 9: Dictionaries and Sets

ملء الشاشة (f)
exit full mode
سؤال
You would typically use a for loop to iterate over the elements in a set.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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
سؤال
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
سؤال
Sets are immutable.
سؤال
Sets are created using curly braces { }.
سؤال
Which would you use to get the number of elements in a dictionary?

A) size
B) length
C) len
D) sizeof
سؤال
If you try to retrieve a value from a dictionary using a nonexistent key,a KeyError exception is raised.
سؤال
The elements in a dictionary are stored in ascending order,by the keys of the key-value pairs.
سؤال
Which method would you use to get all the elements in a dictionary returned as a list of tuples?

A) list
B) items
C) pop
D) keys
سؤال
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' }
سؤال
Which would you use to delete an existing key-value pair from a dictionary?

A) del
B) remove
C) delete
D) unpair
سؤال
The difference of set1 and aet2 is a set that contains only the elements that appear in set1 but do not appear in set2.
سؤال
A dictionary can include the same value several times but cannot include the same key several times.
سؤال
The issubset()method can be used to determine whether set1 is a subset of set2.
سؤال
In a dictionary,you use a(n)__________ to locate a specific value.

A) datum
B) element
C) item
D) key
سؤال
Which method can be used to add a group of elements to a set?

A) add
B) addgroup
C) update
D) addset
سؤال
The union of two sets is a set that contains only the elements that appear in both sets.
سؤال
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.
سؤال
The set remove and discard methods behave differently only when a specified item is not found in the set.
سؤال
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.
سؤال
To add a single item to a set,you can use the set __________ method.
سؤال
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.
سؤال
The __________ method clears the contents of a dictionary.
سؤال
The built-in function,__________,returns the number of items in a set.
سؤال
To write an object to a file,you use the __________ function of the __________ module.
سؤال
Each element in a(n)__________ has two parts: a key and a value.
سؤال
The elements in a dictionary are not stored in a specific order.
Therefore,a dictionary is not a(n)___________.
سؤال
Each element in a dictionary view is a __________.
سؤال
The __________ method returns a value associated with a specific key and,if found,removes that key-value pair from the dictionary.
سؤال
What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)
<strong>What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)  </strong> A) {'FL': 'Tallahassee'} B) KeyError C) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta', 'FL' 'Tallahassee'} D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'} <div style=padding-top: 35px>

A) {'FL': 'Tallahassee'}
B) KeyError
C) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta', 'FL' 'Tallahassee'}
D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}
سؤال
What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)
<strong>What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)  </strong> A) {'FL': 'Tallahassee'} B) KeyError C) {'GA': 'Atlanta', 'FL': 'Tallahassee', 'NY': 'Albany', 'CA': 'San Diego'} D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'} <div style=padding-top: 35px>

A) {'FL': 'Tallahassee'}
B) KeyError
C) {'GA': 'Atlanta', 'FL': 'Tallahassee', 'NY': 'Albany', 'CA': 'San Diego'}
D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}
سؤال
A(n)__________ is an object that holds multiple unique items of data in an unordered manner.
سؤال
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
سؤال
What is the process used to convert an object to a stream of bytes that can be saved in a file?

A) pickling
B) streaming
C) writing
D) dumping
سؤال
The __________ method returns all of a dictionary's keys as a dictionary view.
سؤال
What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)
<strong>What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)  </strong> A) {'CA': 'Sacramento'} B) ['CA': 'Sacramento'] C) {'NY': 'Albany', 'GA': 'Atlanta'} D) {'CA': 'Sacramento', 'NY': 'Albany', 'GA': 'Atlanta'} <div style=padding-top: 35px>

A) {'CA': 'Sacramento'}
B) ['CA': 'Sacramento']
C) {'NY': 'Albany', 'GA': 'Atlanta'}
D) {'CA': 'Sacramento', 'NY': 'Albany', 'GA': 'Atlanta'}
سؤال
To determine whether or not a key is included in a dictionary,or if an element is included in a set,you can use the ___________ operator.
سؤال
The __________ of two sets is a set that contains all the elements of both sets.
سؤال
Which of the following does not apply to sets?

A) The stored elements can be of different data types.
B) All the elements must be unique; you cannot have two elements with the same value.
C) The elements are unordered.
D) The elements are in pairs.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/39
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Dictionaries and Sets
1
You would typically use a for loop to iterate over the elements in a set.
True
2
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
C
3
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
D
4
Sets are immutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
5
Sets are created using curly braces { }.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which would you use to get the number of elements in a dictionary?

A) size
B) length
C) len
D) sizeof
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
7
If you try to retrieve a value from a dictionary using a nonexistent key,a KeyError exception is raised.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
8
The elements in a dictionary are stored in ascending order,by the keys of the key-value pairs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which method would you use to get all the elements in a dictionary returned as a list of tuples?

A) list
B) items
C) pop
D) keys
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
10
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' }
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which would you use to delete an existing key-value pair from a dictionary?

A) del
B) remove
C) delete
D) unpair
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
12
The difference of set1 and aet2 is a set that contains only the elements that appear in set1 but do not appear in set2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
13
A dictionary can include the same value several times but cannot include the same key several times.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
14
The issubset()method can be used to determine whether set1 is a subset of set2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
15
In a dictionary,you use a(n)__________ to locate a specific value.

A) datum
B) element
C) item
D) key
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which method can be used to add a group of elements to a set?

A) add
B) addgroup
C) update
D) addset
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
17
The union of two sets is a set that contains only the elements that appear in both sets.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
18
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
19
The set remove and discard methods behave differently only when a specified item is not found in the set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
20
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
21
To add a single item to a set,you can use the set __________ method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
22
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
23
The __________ method clears the contents of a dictionary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
24
The built-in function,__________,returns the number of items in a set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
25
To write an object to a file,you use the __________ function of the __________ module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
26
Each element in a(n)__________ has two parts: a key and a value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
27
The elements in a dictionary are not stored in a specific order.
Therefore,a dictionary is not a(n)___________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
28
Each element in a dictionary view is a __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
29
The __________ method returns a value associated with a specific key and,if found,removes that key-value pair from the dictionary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
30
What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)
<strong>What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)  </strong> A) {'FL': 'Tallahassee'} B) KeyError C) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta', 'FL' 'Tallahassee'} D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}

A) {'FL': 'Tallahassee'}
B) KeyError
C) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta', 'FL' 'Tallahassee'}
D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
31
What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)
<strong>What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)  </strong> A) {'FL': 'Tallahassee'} B) KeyError C) {'GA': 'Atlanta', 'FL': 'Tallahassee', 'NY': 'Albany', 'CA': 'San Diego'} D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}

A) {'FL': 'Tallahassee'}
B) KeyError
C) {'GA': 'Atlanta', 'FL': 'Tallahassee', 'NY': 'Albany', 'CA': 'San Diego'}
D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
32
A(n)__________ is an object that holds multiple unique items of data in an unordered manner.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
33
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
34
What is the process used to convert an object to a stream of bytes that can be saved in a file?

A) pickling
B) streaming
C) writing
D) dumping
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
35
The __________ method returns all of a dictionary's keys as a dictionary view.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
36
What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)
<strong>What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.)  </strong> A) {'CA': 'Sacramento'} B) ['CA': 'Sacramento'] C) {'NY': 'Albany', 'GA': 'Atlanta'} D) {'CA': 'Sacramento', 'NY': 'Albany', 'GA': 'Atlanta'}

A) {'CA': 'Sacramento'}
B) ['CA': 'Sacramento']
C) {'NY': 'Albany', 'GA': 'Atlanta'}
D) {'CA': 'Sacramento', 'NY': 'Albany', 'GA': 'Atlanta'}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
37
To determine whether or not a key is included in a dictionary,or if an element is included in a set,you can use the ___________ operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
38
The __________ of two sets is a set that contains all the elements of both sets.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which of the following does not apply to sets?

A) The stored elements can be of different data types.
B) All the elements must be unique; you cannot have two elements with the same value.
C) The elements are unordered.
D) The elements are in pairs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.