Chapter 7 List and Tuples Flashcards

1
Q

Which method can be used to place an item at a specific index in a list?

a. append
b. insert
c. index
d. add

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which method or operator can be used to concatenate lists?

a. *
b. +
c. concat
d. %

A

+

Chapter 7 Q (page# 349)

The + operator is used to concatenate two lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Arrays, which are allowed by most other programming languages have more capabilities than Python list structures.
True or False?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

False

Chapter 7 Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When working with multiple sets of data, one would typically use a(n)

a. tuple
b. sequence
c. nested list
d. list

A

nested list

Chapter 7 Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which method can be used to convert a list to a tuple?

a. insert
b. tuple
c. append
d. list

A

tuple

Chapter 7 Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

A

[1, 2, 3, 10]

Chapter 7 Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The index -1 identifies the last element in a list.

True or False?

A

True

Chapter 7 Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the data items in a list called?

a. values
b. elements
c. items
d. data

A

elements

Chapter 7 Q

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
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?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly