Deck 4: Introducing the Python Collections: Lists, Dictionaries, Tuples, and Statistics

ملء الشاشة (f)
exit full mode
سؤال
Case Study 1:
1. >>> m
2. >>> ??????
3. print(answer)
Output:
A
B
E
A
D
B
B
A
C
E
-Refer to the session in the accompanying Case Study 1. What program statements appear on line 2 to create the output listed in the case study?

A) if answer in myAnswers:
B) for answer in myAnswers:
C) print myAnswers:
D) for answer = myAnswers:
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
How is an empty list represented in Python?

A) []
B) ()
C) **
D) &It;>
سؤال
What will be the output based on the following lines of code?
>>> myList = [3, "cat", 6.5, 2]
>>> myList

A) 3
B) 4
C) [3, 'cat', 6.5, 2]
D) An error message because a list cannot contain different types of data
سؤال
What is the membership operator for lists?

A) []
B) +
C) *
D) in
سؤال
Case Study 2:
>>> changeList = [1, 2, "buckle my shoe", 3, 4,
"shut the door"]
2. >>> changeList
3. [1, 2, 'buckle my shoe', 3, 4, 'shut the door']
4. >>> changeList[2] = "the sky is blue"
5. >>> changeList
6. ??????
7. >>> name = "Monte"
8. >>> name[2] = "x"
9. ??????
-Refer to the session in the accompanying Case Study 2. What will be the output on line 6?

A) 'the sky is blue'
B) [1, 'the sky is blue', "buckle my shoe", 3, 4, 'shut the door']
C) [1, 2, 'the sky is blue', 3, 4, 'shut the door']
D) TypeError:object does not support item assignment
سؤال
Case Study 2:
>>> changeList = [1, 2, "buckle my shoe", 3, 4,
"shut the door"]
2. >>> changeList
3. [1, 2, 'buckle my shoe', 3, 4, 'shut the door']
4. >>> changeList[2] = "the sky is blue"
5. >>> changeList
6. ??????
7. >>> name = "Monte"
8. >>> name[2] = "x"
9. ??????
-Refer to the session in the accompanying Case Study 2. What will be the output on line 9?

A) "Monte"
B) "x"
C) "Moxte"
D) TypeError:object does not support item assignment
سؤال
Python provides the ____ function to create a list from a range or string.

A) list
B) append
C) insert
D) []
سؤال
The ____ list function removes and returns the last item in a list.

A) pop()
B) reverse()
C) remove(item)
D) count(item)
سؤال
One of the most often used measures of a collection of data is known as:

A) range.
B) central tendency.
C) dispersion.
D) mode.
سؤال
A Python ____ is a collection of associated pairs of items where each pair consists of a key and a value.

A) list
B) range
C) dictionary
D) string
سؤال
Case Study 3:
>>> ages = {'David':45, 'Brenda':46}
>>> ages
{'David': 45, 'Brenda': 46}
>>>
-Refer to the session in the accompanying Case Study 3. What will be the output after the following statement?
>>> ages['David']

A) {'David': 45}
B) 45
C) 'Brenda'
D) ages
سؤال
Case Study 3:
>>> ages = {'David':45, 'Brenda':46}
>>> ages
{'David': 45, 'Brenda': 46}
>>>
-Refer to the session in the accompanying Case Study 3. What will be the output after the following statement?
>>> ages['Kelsey'] = 19
>>> ages

A) 19
B) 'Kelsey'
C) {'Kelsey': 19}
D) {'David': 45, 'Brenda': 46, 'Kelsey': 19}
سؤال
What method is used to retrieve the value from a dictionary associated with a given key?

A) values
B) keys
C) get
D) del
سؤال
What statement is used to remove an entry from a dictionary based on a given key?

A) get
B) keys
C) del
D) index
سؤال
What represents the value(s) that occur most often in a set of data?

A) Average
B) Mode
C) Mean
D) Frequency distribution
سؤال
Lists in Python are sequences.
سؤال
Strings are mutable collections of data in which individual items within the string cannot be changed.
سؤال
The following Python statement creates a list of even numbers in ascending order:
list(range(10, 2, -2))
سؤال
Case Study 3:
>>> ages = {'David':45, 'Brenda':46}
>>> ages
{'David': 45, 'Brenda': 46}
>>>
-Refer to the session in the accompanying Case Study 3. The reference ages refers to a list.
سؤال
The values() method returns a dict_values object that behaves much like a list of the values in a dictionary.
سؤال
Match each definition with its term.
-Found by locating the item that occurs in the exact middle of a collection.

A) Median
B) Mode
C) Dispersion
D) Mean
سؤال
Match each definition with its term.
-The most frequently occurring value in a collection.

A) Median
B) Mode
C) Dispersion
D) Mean
سؤال
Match each definition with its term.
-Measure of how spread out data values in a collection are.

A) Median
B) Mode
C) Dispersion
D) Mean
سؤال
Match each definition with its term.
-Calculated by adding up the values in a collection and dividing by the number of items.

A) Median
B) Mode
C) Dispersion
D) Mean
سؤال
Define the concept of a list and describe some specific characteristics of lists in Python.
سؤال
Explain the meaning of the terms mutable and immutable.
سؤال
Describe the use of the split method for lists and provide an example of its use.
سؤال
How can Python be used to calculate dispersion?
سؤال
An interesting question arises when we consider what would happen if we did not have a built-in function to return the maximum value in the list. We could conceivably construct our own getMax function by iterating through the items in the list and keeping track of the largest value that we encounter. Provide an implementation of such a function.
سؤال
How would you use Python to find the mean value in a list?
سؤال
How would you find the mode of a list in Python?
سؤال
Describe two characteristics of Python dictionaries.
سؤال
How might you use Python to visualize a frequency distribution?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/33
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Introducing the Python Collections: Lists, Dictionaries, Tuples, and Statistics
1
Case Study 1:
1. >>> m
2. >>> ??????
3. print(answer)
Output:
A
B
E
A
D
B
B
A
C
E
-Refer to the session in the accompanying Case Study 1. What program statements appear on line 2 to create the output listed in the case study?

A) if answer in myAnswers:
B) for answer in myAnswers:
C) print myAnswers:
D) for answer = myAnswers:
B
2
How is an empty list represented in Python?

A) []
B) ()
C) **
D) &It;>
A
3
What will be the output based on the following lines of code?
>>> myList = [3, "cat", 6.5, 2]
>>> myList

A) 3
B) 4
C) [3, 'cat', 6.5, 2]
D) An error message because a list cannot contain different types of data
C
4
What is the membership operator for lists?

A) []
B) +
C) *
D) in
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
5
Case Study 2:
>>> changeList = [1, 2, "buckle my shoe", 3, 4,
"shut the door"]
2. >>> changeList
3. [1, 2, 'buckle my shoe', 3, 4, 'shut the door']
4. >>> changeList[2] = "the sky is blue"
5. >>> changeList
6. ??????
7. >>> name = "Monte"
8. >>> name[2] = "x"
9. ??????
-Refer to the session in the accompanying Case Study 2. What will be the output on line 6?

A) 'the sky is blue'
B) [1, 'the sky is blue', "buckle my shoe", 3, 4, 'shut the door']
C) [1, 2, 'the sky is blue', 3, 4, 'shut the door']
D) TypeError:object does not support item assignment
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
6
Case Study 2:
>>> changeList = [1, 2, "buckle my shoe", 3, 4,
"shut the door"]
2. >>> changeList
3. [1, 2, 'buckle my shoe', 3, 4, 'shut the door']
4. >>> changeList[2] = "the sky is blue"
5. >>> changeList
6. ??????
7. >>> name = "Monte"
8. >>> name[2] = "x"
9. ??????
-Refer to the session in the accompanying Case Study 2. What will be the output on line 9?

A) "Monte"
B) "x"
C) "Moxte"
D) TypeError:object does not support item assignment
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
7
Python provides the ____ function to create a list from a range or string.

A) list
B) append
C) insert
D) []
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
8
The ____ list function removes and returns the last item in a list.

A) pop()
B) reverse()
C) remove(item)
D) count(item)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
9
One of the most often used measures of a collection of data is known as:

A) range.
B) central tendency.
C) dispersion.
D) mode.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
10
A Python ____ is a collection of associated pairs of items where each pair consists of a key and a value.

A) list
B) range
C) dictionary
D) string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
11
Case Study 3:
>>> ages = {'David':45, 'Brenda':46}
>>> ages
{'David': 45, 'Brenda': 46}
>>>
-Refer to the session in the accompanying Case Study 3. What will be the output after the following statement?
>>> ages['David']

A) {'David': 45}
B) 45
C) 'Brenda'
D) ages
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
12
Case Study 3:
>>> ages = {'David':45, 'Brenda':46}
>>> ages
{'David': 45, 'Brenda': 46}
>>>
-Refer to the session in the accompanying Case Study 3. What will be the output after the following statement?
>>> ages['Kelsey'] = 19
>>> ages

A) 19
B) 'Kelsey'
C) {'Kelsey': 19}
D) {'David': 45, 'Brenda': 46, 'Kelsey': 19}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
13
What method is used to retrieve the value from a dictionary associated with a given key?

A) values
B) keys
C) get
D) del
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
14
What statement is used to remove an entry from a dictionary based on a given key?

A) get
B) keys
C) del
D) index
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
15
What represents the value(s) that occur most often in a set of data?

A) Average
B) Mode
C) Mean
D) Frequency distribution
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
16
Lists in Python are sequences.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
17
Strings are mutable collections of data in which individual items within the string cannot be changed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
18
The following Python statement creates a list of even numbers in ascending order:
list(range(10, 2, -2))
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
19
Case Study 3:
>>> ages = {'David':45, 'Brenda':46}
>>> ages
{'David': 45, 'Brenda': 46}
>>>
-Refer to the session in the accompanying Case Study 3. The reference ages refers to a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
20
The values() method returns a dict_values object that behaves much like a list of the values in a dictionary.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
21
Match each definition with its term.
-Found by locating the item that occurs in the exact middle of a collection.

A) Median
B) Mode
C) Dispersion
D) Mean
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
22
Match each definition with its term.
-The most frequently occurring value in a collection.

A) Median
B) Mode
C) Dispersion
D) Mean
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
23
Match each definition with its term.
-Measure of how spread out data values in a collection are.

A) Median
B) Mode
C) Dispersion
D) Mean
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
24
Match each definition with its term.
-Calculated by adding up the values in a collection and dividing by the number of items.

A) Median
B) Mode
C) Dispersion
D) Mean
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
25
Define the concept of a list and describe some specific characteristics of lists in Python.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
26
Explain the meaning of the terms mutable and immutable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
27
Describe the use of the split method for lists and provide an example of its use.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
28
How can Python be used to calculate dispersion?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
29
An interesting question arises when we consider what would happen if we did not have a built-in function to return the maximum value in the list. We could conceivably construct our own getMax function by iterating through the items in the list and keeping track of the largest value that we encounter. Provide an implementation of such a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
30
How would you use Python to find the mean value in a list?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
31
How would you find the mode of a list in Python?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
32
Describe two characteristics of Python dictionaries.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
33
How might you use Python to visualize a frequency distribution?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 33 في هذه المجموعة.