Deck 9: Dictionaries and Sets
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/33
العب
ملء الشاشة (f)
Deck 9: Dictionaries and Sets
1
The values of an associative data structure are unordered.
True
2
The location that an element is stored in and retrieved from in an associative data structure depends on both its key value and its index value.
False
3
The dictionary type in Python is an associative data structure.
True
4
The dictionary type in Python is of variable length.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
5
A dictionary may be contained within another dictionary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
6
Dictionaries in Python are
A) mutable
B) immutable
C) neither mutable nor immutable
D) mutable or immutable, depending on the situation
E) none of the above
A) mutable
B) immutable
C) neither mutable nor immutable
D) mutable or immutable, depending on the situation
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following contains the proper Python syntax for defining a dictionary?
A) fruitPrices = ['bananas' : 1.00, 'apples' : 1.50, 'pears' : 2.00]
B) fruitPrices = {'bananas' : 1.00, 'apples' : 1.50, 'pears' : 2.00}
C) monthlyIncome = [['March', 2000], ['April', 2300], ['May', 1900]]
D) firstFiveInts = {1, 2, 3, 4, 5}
E) None of the above
A) fruitPrices = ['bananas' : 1.00, 'apples' : 1.50, 'pears' : 2.00]
B) fruitPrices = {'bananas' : 1.00, 'apples' : 1.50, 'pears' : 2.00}
C) monthlyIncome = [['March', 2000], ['April', 2300], ['May', 1900]]
D) firstFiveInts = {1, 2, 3, 4, 5}
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following CANNOT be used as a key value in a dictionary?
A) integers
B) strings
C) tuples
D) lists
E) all of the above
A) integers
B) strings
C) tuples
D) lists
E) all of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following is NOT valid in Python for dictionary d?
A) d = dict()
B) d['apples'] , for key value 'apples' in d
C) len(d)
D) 'apples' in d
E) del 'apples'
A) d = dict()
B) d['apples'] , for key value 'apples' in d
C) len(d)
D) 'apples' in d
E) del 'apples'
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
10
The values stored in a dictionary are assigned/retrieved by use of a corresponding key value. Therefore, dictionaries in Python are an ___________________ data structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
11
The location that a given value is stored in a dictionary in Python is determined by its key value. The process of determing the storge location of a value based on the value itself is called __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
12
Three example of the types of values that be used as key values of dictionaries in Python are _____________, ________________, and _______________..
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
13
Define a dictionary named spanish_days that contains as key values the days of the week ('Sunday', 'Monday', etc), in which each key value has the corresponding name in Spanish ('Domingo','Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado').
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
14
Assuming that dictionary spanish_days from the question above has been defined, give an instruction that uses spanish_days to display "The word for Monday in Spanish is Lunes".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
15
Assuming the dictionary spanish_days from the question above has been defined, and that variable day contains one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' and 'Sunday'. Give an instructions that displays "The word for english_dayname in Spanish is Spanish_dayname".
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
16
A set in Python is a mutable data type, and a frozenset is an immutable type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
17
The set type provides the usual mathematical opertions on sets (e.g., intersection, union).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
18
As with the dictionary type in Python, the values of a set or frozenset type are unordered.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
19
A set stores only one instance of each value, but keeps track of how many instances of each value have been attempted to be added to the set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
20
A new empty set is created by use of empty curly braces.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
21
As with sequence types, the in operator is used to determine if a particular value is in given set.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following is true of sets / frozensets in Python?
A) sets are immutable, and frozensets are mutable
B) sets are mutable and frozensets are both ordered data structures
C) sets are ordered mutable data structures, frozensets are unordered and immutable
D) sets are unordered mutable data structures, frozensets are unordered and immutable
E) none of the above
A) sets are immutable, and frozensets are mutable
B) sets are mutable and frozensets are both ordered data structures
C) sets are ordered mutable data structures, frozensets are unordered and immutable
D) sets are unordered mutable data structures, frozensets are unordered and immutable
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
23
The following instruction in Python creates
New_datastruc = { }
A) an empty set
B) an empty frozenset
C) an empty dictionary
D) special value None
E) none of the above
New_datastruc = { }
A) an empty set
B) an empty frozenset
C) an empty dictionary
D) special value None
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which of the following is NOT valid in Python for set s1 and s2?
A) 'apples' in s1
B) s1 | s2
C) s1 + s2
D) s1 - S2
E) s1 & s2
A) 'apples' in s1
B) s1 | s2
C) s1 + s2
D) s1 - S2
E) s1 & s2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which of the following is the correct way to declare a new set?
A) s = new('apples', 'pears', 'bananas')
B) s = new( ('apples', 'pears', bananas') )
C) s = set('apples', 'pears', 'bananas')
D) s = set( ('apples', 'pears', 'bananas') )
E) none of the above
A) s = new('apples', 'pears', 'bananas')
B) s = new( ('apples', 'pears', bananas') )
C) s = set('apples', 'pears', 'bananas')
D) s = set( ('apples', 'pears', 'bananas') )
E) none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
26
The set type in Python is ______________ , which the frozenset type is __________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
27
The set type in Python provides the usual mathematical operations of union, _____________, and ______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
28
In order to create an empty set, ___________ is used, not a pair of empty braces, { }.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
29
The proper syntax for creating a set containing the values 'apple', 'pear', and 'banana' is __________________________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
30
Define a set named colors that contains the following colors: 'red', 'blue', 'green', 'yellow'.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
31
Assuming that two set of color names have been defined, color1 and color2, give the expression that would produce the names of the colors that are
(a) in either color1 or color2
(b) in both color1 and color2
(c) in color1 but not in color2
(d) in either color1 or color2, but not both
(a) in either color1 or color2
(b) in both color1 and color2
(c) in color1 but not in color2
(d) in either color1 or color2, but not both
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
32
Declare a set named RGB_primarycolors containing the values 'red', 'green', and 'blue', such that the set is immutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
33
In the additive (RGB) color model, red and green produce yellow, green and blue produce cyan, and blue and red produce magenta. Define a dictionary named additive_colormixing able to be given any two of these primary colors, and retrieve the resulting color from the combining of the two.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck