Deck 10: Dictionaries and Sets

ملء الشاشة (f)
exit full mode
سؤال
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 - no two elements can have the same value.
C) The elements are unordered.
D) The elements are pairs.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
What would 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 created using curly braces {}.
سؤال
A dictionary can include the same value several times, but cannot include the same key several times.
سؤال
What does the get method do if the specified key is not found in the dictionary?

A) Throw an exception
B) Nothing
C) Return a default value
D) You do not specify a key for the get method
سؤال
Which function would you use to get the number of elements in a dictionary?

A) size
B) length
C) len
D) invalid code
سؤال
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
سؤال
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.
سؤال
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
سؤال
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' }
سؤال
What is the number of the first index in a list dictionary?

A) 0
B) 1
C) Dictionary is not indexed by number.
D) Size of the dictionary minus one.
سؤال
In a dictionary, you use a(n) _____ to locate a specific value.

A) datum
B) element
C) item
D) key
سؤال
Which statement would you use to delete an existing key-value pair from a dictionary?

A) del
B) remove
C) delete
D) unpair
سؤال
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
سؤال
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
سؤال
Sets are immutable.
سؤال
You would typically use a for loop to iterate over the elements in a set.
سؤال
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.
سؤال
Which method would you use to return the value associated with a specified key and remove that key-value pair from the dictionary?

A) list
B) items
C) popitem
D) pop
سؤال
The set remove and discard methods behave differently only when a specified item is not found in the set.
سؤال
The _______________ of two sets is a set that contains all the elements of both sets.
سؤال
The union of two sets is a set that contains only the elements that appear in both sets.
سؤال
The index of the first key-value pair in a dictionary is 0.
سؤال
The _______________ method returns a value associated with a specified key and if found, removes that key-value pair from the dictionary.
سؤال
The elements in a dictionary are not stored in a specific order. Therefore a dictionary is not a(n) _______________.
سؤال
To add a single item to a set, you can use the set method _______________.
سؤال
To write an object to a file, you use the _______________ function of the _______________ module.
سؤال
The index of the first element in a set is 0.
سؤال
Each element in a(n) _______________ has two parts: a key and a value.
سؤال
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.
سؤال
The built-in function _______________ returns the number of items in a set.
سؤال
A(n) _______________ is an object that holds multiple unique items of data in an unordered manner.
سؤال
The _______________ method clears the contents of a dictionary.
سؤال
The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2.
سؤال
The issubset method can be used to determine whether set1 is a subset of set2.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/35
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 10: Dictionaries and Sets
1
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 - no two elements can have the same value.
C) The elements are unordered.
D) The elements are pairs.
D
2
What would 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
3
Sets are created using curly braces {}.
False
4
A dictionary can include the same value several times, but cannot include the same key several times.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
5
What does the get method do if the specified key is not found in the dictionary?

A) Throw an exception
B) Nothing
C) Return a default value
D) You do not specify a key for the get method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which function would you use to get the number of elements in a dictionary?

A) size
B) length
C) len
D) invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
7
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
8
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
9
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
10
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' }
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
11
What is the number of the first index in a list dictionary?

A) 0
B) 1
C) Dictionary is not indexed by number.
D) Size of the dictionary minus one.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
12
In a dictionary, you use a(n) _____ to locate a specific value.

A) datum
B) element
C) item
D) key
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which statement would you use to delete an existing key-value pair from a dictionary?

A) del
B) remove
C) delete
D) unpair
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
14
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
15
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
16
Sets are immutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
17
You would typically use a for loop to iterate over the elements in a set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
18
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which method would you use to return the value associated with a specified key and remove that key-value pair from the dictionary?

A) list
B) items
C) popitem
D) pop
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
20
The set remove and discard methods behave differently only when a specified item is not found in the set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
21
The _______________ of two sets is a set that contains all the elements of both sets.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
22
The union of two sets is a set that contains only the elements that appear in both sets.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
23
The index of the first key-value pair in a dictionary is 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
24
The _______________ method returns a value associated with a specified key and if found, removes that key-value pair from the dictionary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
25
The elements in a dictionary are not stored in a specific order. Therefore a dictionary is not a(n) _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
26
To add a single item to a set, you can use the set method _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
27
To write an object to a file, you use the _______________ function of the _______________ module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
28
The index of the first element in a set is 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
29
Each element in a(n) _______________ has two parts: a key and a value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
31
The built-in function _______________ returns the number of items in a set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
32
A(n) _______________ is an object that holds multiple unique items of data in an unordered manner.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
33
The _______________ method clears the contents of a dictionary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
34
The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
35
The issubset method can be used to determine whether set1 is a subset of set2.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.