Chapter 7 List and Tuples Flashcards
Which method can be used to place an item at a specific index in a list?
a. append
b. insert
c. index
d. add
insert
Chapter 7 Q (page# 359)
The insert method allows you to insert an item into a list at a specific position. You pass two arguments to the insert method: an index specifying where the item should be inserted and the item that you want to insert.
Which method or operator can be used to concatenate lists?
a. *
b. +
c. concat
d. %
+
Chapter 7 Q (page# 349)
The + operator is used to concatenate two lists.
Arrays, which are allowed by most other programming languages have more capabilities than Python list structures.
True or False?
False
Chapter 7 Q (page# 345)
Most programming languages allow you to create sequence structures known as arrays, which are similar to list, but are much more limited in their capabilities. You cannot create traditional arrays in Python because lists serve the same purpose and provide many more built-in capabilities.
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.
True or False?
False
Chapter 7 Q
When working with multiple sets of data, one would typically use a(n)
a. tuple
b. sequence
c. nested list
d. list
nested list
Chapter 7 Q
Which method can be used to convert a list to a tuple?
a. insert
b. tuple
c. append
d. list
tuple
Chapter 7 Q
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. 10, 4]
b. [1, 10, 10, 10]
c. [1, 2, 3, 10]
d. Nothing: this code is invalid.
[1, 2, 3, 10]
Chapter 7 Q
The index -1 identifies the last element in a list.
True or False?
True
Chapter 7 Q
What are the data items in a list called?
a. values
b. elements
c. items
d. data
elements
Chapter 7 Q
In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.
True or False?
True
Chapter 7 Q (page# 352)
If you leave out the end index in a slicing expression, it will use the length of the list as the end