Deck 7: Lists and Tuples
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
العب
ملء الشاشة (f)
Deck 7: Lists and Tuples
1
The index of the first element in a list is 1,the index of the second element is 2,and so forth.
False
2
The remove method removes all occurrences of an item from a list.
False
3
To add a descriptive label to the X and Y axes of a graph when using the matplotlib package,you need to import the labels module.
False
4
The primary difference between a tuple and a list is that
A) you don't use commas to separate elements in a tuple
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
A) you don't use commas to separate elements in a tuple
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
What are the data items in a list called?
A) data
B) elements
C) items
D) values
A) data
B) elements
C) items
D) values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
In slicing,if the end index specifies a position beyond the end of the list,Python will use the length of the list instead.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following would you use if an element is to be removed from a specific index?
A) a del statement
B) a remove method
C) an index method
D) a slice method
A) a del statement
B) a remove method
C) an index method
D) a slice method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
What is an advantage of using a tuple rather than a list?
A) Tuples are not limited in size.
B) Tuples can include any data as an element.
C) Processing a tuple is faster than processing a list.
D) There is never an advantage to using a tuple.
A) Tuples are not limited in size.
B) Tuples can include any data as an element.
C) Processing a tuple is faster than processing a list.
D) There is never an advantage to using a tuple.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
Lists are dynamic data structures such that items may be added to them or removed from them.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which list will be referenced by the variable number after the following code is executed?
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]
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]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
In order to create graphs using the matplotlib package,you need to import the pyplot module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
Arrays,which are allowed by most other programming languages,have more capabilities than Python list structures.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
Invalid indexes do not cause slicing expressions to raise an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
The sort method rearranges the elements of a list so they are in ascending or descending order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
A list cannot be passed as an argument to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
What is the first negative index in a list?
A) 0
B) -1
C) -0
D) the size of the list minus 1
A) 0
B) -1
C) -0
D) the size of the list minus 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
The index -1 identifies the last element in a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
To calculate the average of the numeric values in a list,the first step is to get the total of values in the list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which method can be used to place an item at a specific index in a list?
A) append
B) index
C) insert
D) add
A) append
B) index
C) insert
D) add
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
When working with multiple sets of data,one would typically use a(n)
A) list
B) tuple
C) nested list
D) sequence
A) list
B) tuple
C) nested list
D) sequence
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
The ___________ function can be used to convert a list to a tuple.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
Lists are ___________,which means their elements can be changed in a program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
What will be the value of the variable list2 after the following code executes?
![<strong>What will be the value of the variable list2 after the following code executes? </strong> A) [1, 2, 3] B) [4, 5, 6] C) [1, 2, 3, 4, 5, 6] D) Nothing; this code is invalid](https://d2lvgg3v3hfg70.cloudfront.net/TB6553/11ea66a4_b3c4_7e34_9a9a_dfc2c394bfd1_TB6553_00.jpg)
A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) Nothing; this code is invalid
![<strong>What will be the value of the variable list2 after the following code executes? </strong> A) [1, 2, 3] B) [4, 5, 6] C) [1, 2, 3, 4, 5, 6] D) Nothing; this code is invalid](https://d2lvgg3v3hfg70.cloudfront.net/TB6553/11ea66a4_b3c4_7e34_9a9a_dfc2c394bfd1_TB6553_00.jpg)
A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) Nothing; this code is invalid
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which method or operator can be used to concatenate lists?
A) *
B) +
C) %
D) concat
A) *
B) +
C) %
D) concat
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which method can be used to convert a list to a tuple?
A) append
B) tuple
C) insert
D) list
A) append
B) tuple
C) insert
D) list
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
The built-in function __________ returns the length of a sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
Tuples are __________ sequences which means that once a tuple is created,it cannot be changed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
A(n)___________ is a span of items that are taken from a sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
What will be the value of the variable list after the following code executes?
List = [1,2,3,4]
List[3] = 10
A) [1, 2, 3, 10]
B) [1, 2, 10, 4]
C) [1, 10, 10, 10]
D) Nothing; this code is invalid
List = [1,2,3,4]
List[3] = 10
A) [1, 2, 3, 10]
B) [1, 2, 10, 4]
C) [1, 10, 10, 10]
D) Nothing; this code is invalid
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
The __________ package is a library you can use in Python to create two-dimensional charts and graphs.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
The __________ function returns the item that has the lowest value in the sequence.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
Each element in a tuple has a(n)__________ that specifies its position in the tuple.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
What will be the output after the following code is executed?

A) It will display a simple line graph.
B) It will display a simple bar graph.
C) Nothing; plt is not a Python method.
D) Nothing; the number of x-coordinates do not match the number of y-coordinates.

A) It will display a simple line graph.
B) It will display a simple bar graph.
C) Nothing; plt is not a Python method.
D) Nothing; the number of x-coordinates do not match the number of y-coordinates.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which method can be used to convert a tuple to a list?
A) append
B) tuple
C) insert
D) list
A) append
B) tuple
C) insert
D) list
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
In order to create a graph in Python,you need to include
A) import matplotlib
B) import pyplot
C) import matplotlib.pyplot
D) import matplotlib
Import pyplot
A) import matplotlib
B) import pyplot
C) import matplotlib.pyplot
D) import matplotlib
Import pyplot
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
What will be the value of the variable list after the following code executes?
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]
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]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
The __________ method reverses the order of the items in a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
The __________ exception is raised when a search item is not in the list being searched.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
A(n)__________ is an object that holds multiple items of data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
The __________ method is commonly used to add items to a list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck