Deck 8: Lists and Tuples

ملء الشاشة (f)
exit full mode
سؤال
What method can be used to place an item in the list at a specific index?

A) append
B) index
C) insert
D) Add
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which list will be referenced by the variable number after the execution of the following code? number = range(0, 9, 2)

A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B) [1, 3, 5, 7, 9]
C) [2, 4, 6, 8]
D) [0, 2, 4, 6, 8]
سؤال
What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3]
List2 = []
For element in list1
List2.append(element)
List1 = [4, 5, 6]

A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) invalid code
سؤال
What are the data items in the list called?

A) data
B) elements
C) items
D) values
سؤال
When working with multiple sets of data, one would typically use a(n) _____.

A) list
B) tuple
C) nested list
D) Sequence
سؤال
What is the advantage of using tuples over lists?

A) Tuples are not limited in size.
B) Tuples can include any data type as an element.
C) Processing a tuple is faster than processing a list.
D) There is no advantage.
سؤال
What would you use if an element is to be removed from a specific index?

A) del statement
B) remove method
C) index method
D) slice method
سؤال
What method can be used to convert a tuple to a list?

A) append
B) tuple
C) insert
D) list
سؤال
The remove method removes all occurrences of the item from a list.
سؤال
What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3]
List2 = list1
List1 = [4, 5, 6]

A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) invalid code
سؤال
The primary difference between a tuple and list is that _____.

A) when creating a tuple you don't use commas to separate elements
B) a tuple can only include string elements
C) a tuple cannot include lists as elements
D) once a tuple is created, it cannot be changed
سؤال
What would be the value of the variable list after the execution of the following code? list = [1, 2, 3, 4]
List[3] = 10

A) [1, 2, 3, 10]
B) [1, 2, 10, 4]
C) [1, 10, 10, 10]
D) invalid code
سؤال
What method can be used to convert a list to a tuple?

A) append
B) tuple
C) insert
D) list
سؤال
Invalid indexes do not cause slicing expressions to raise an exception.
سؤال
What would be the value of the variable list after the execution of the following code? list = [1, 2]
List = list * 3

A) [1, 2] * 3
B) [3, 6]
C) [1, 2, 1, 2, 1, 2]
D) [[1, 2], [1, 2], [1, 2]]
سؤال
Lists are dynamic data structures such that items may be added to them or removed from them.
سؤال
A list cannot be passed as an argument to a function.
سؤال
What method or operator can be used to concatenate lists?

A) *
B) +
C) %
D) concat
سؤال
What is the first negative index in a list?

A) 0
B) -1
C) -0
D) Size of the string or list minus one
سؤال
Arrays, which most other programming languages allow, have much more capabilities than list structures.
سؤال
The index - 1 identifies the last element in a list.
سؤال
The sort method rearranges the elements of a list so they appear in ascending or descending order.
سؤال
In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.
سؤال
A(n) _______________ is an object that holds multiple items of data.
سؤال
The _______________ method reverses the order of the items in the list.
سؤال
The _______________ function returns the item that has the lowest value in the sequence.
سؤال
The first step in calculating the average of the values in a list is to get the total of the values.
سؤال
Tuples are _______________ sequences, which means that once a tuple is created, it cannot be changed.
سؤال
The _______________ method is commonly used to add items to a list.
سؤال
The built-in function _______________ returns the length of a sequence.
سؤال
A(n) _______________ is a span of items that are taken from a sequence.
سؤال
Lists are _______________, which means their elements can be changed.
سؤال
Each element in a tuple has a(n) _______________ that specifies its position in the tuple.
سؤال
Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.
سؤال
The _______________ exception is raised when a search item is not in the list being searched.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/35
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 8: Lists and Tuples
1
What method can be used to place an item in the list at a specific index?

A) append
B) index
C) insert
D) Add
C
2
Which list will be referenced by the variable number after the execution of the following code? number = range(0, 9, 2)

A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B) [1, 3, 5, 7, 9]
C) [2, 4, 6, 8]
D) [0, 2, 4, 6, 8]
D
3
What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3]
List2 = []
For element in list1
List2.append(element)
List1 = [4, 5, 6]

A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) invalid code
A
4
What are the data items in the list called?

A) data
B) elements
C) items
D) values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
5
When working with multiple sets of data, one would typically use a(n) _____.

A) list
B) tuple
C) nested list
D) Sequence
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
6
What is the advantage of using tuples over lists?

A) Tuples are not limited in size.
B) Tuples can include any data type as an element.
C) Processing a tuple is faster than processing a list.
D) There is no advantage.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
7
What would you use if an element is to be removed from a specific index?

A) del statement
B) remove method
C) index method
D) slice method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
8
What method can be used to convert a tuple to a list?

A) append
B) tuple
C) insert
D) list
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
9
The remove method removes all occurrences of the item from a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
10
What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3]
List2 = list1
List1 = [4, 5, 6]

A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
11
The primary difference between a tuple and list is that _____.

A) when creating a tuple you don't use commas to separate elements
B) a tuple can only include string elements
C) a tuple cannot include lists as elements
D) once a tuple is created, it cannot be changed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
12
What would be the value of the variable list after the execution of the following code? list = [1, 2, 3, 4]
List[3] = 10

A) [1, 2, 3, 10]
B) [1, 2, 10, 4]
C) [1, 10, 10, 10]
D) invalid code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
13
What method can be used to convert a list to a tuple?

A) append
B) tuple
C) insert
D) list
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
14
Invalid indexes do not cause slicing expressions to raise an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
15
What would be the value of the variable list after the execution of the following code? list = [1, 2]
List = list * 3

A) [1, 2] * 3
B) [3, 6]
C) [1, 2, 1, 2, 1, 2]
D) [[1, 2], [1, 2], [1, 2]]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
16
Lists are dynamic data structures such that items may be added to them or removed from them.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
17
A list cannot be passed as an argument to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
18
What method or operator can be used to concatenate lists?

A) *
B) +
C) %
D) concat
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
19
What is the first negative index in a list?

A) 0
B) -1
C) -0
D) Size of the string or list minus one
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
20
Arrays, which most other programming languages allow, have much more capabilities than list structures.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
21
The index - 1 identifies the last element in a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
22
The sort method rearranges the elements of a list so they appear in ascending or descending order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
23
In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
24
A(n) _______________ is an object that holds multiple items of data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
25
The _______________ method reverses the order of the items in the list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
26
The _______________ function returns the item that has the lowest value in the sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
27
The first step in calculating the average of the values in a list is to get the total of the values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
28
Tuples are _______________ sequences, which means that once a tuple is created, it cannot be changed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
29
The _______________ method is commonly used to add items to a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
30
The built-in function _______________ returns the length of a sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
31
A(n) _______________ is a span of items that are taken from a sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
32
Lists are _______________, which means their elements can be changed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
33
Each element in a tuple has a(n) _______________ that specifies its position in the tuple.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
34
Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
35
The _______________ exception is raised when a search item is not in the list being searched.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 35 في هذه المجموعة.