Ch 7

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

True

To calculate the average of the numeric values in a list, the first step is to get the total of values in the list.

True

Which list will be referenced by the variable number after the following code is executed? number = range(0, 9, 2)

[0, 2, 4, 6, 8]

What will be the value of the variable list after the following code executes? list = [1, 2] list = list * 3

[1, 2, 1, 2, 1, 2]

What will be the value of the variable list after the following code executes? list = [1, 2, 3, 4] list[3] = 10

[1, 2, 3, 10]

What will be the value of the variable list2 after the following code executes? list1 = [1, 2, 3] list2 = [] for element in list1: list2.append(element) list1 = [4, 5, 6]

[1, 2, 3]

Which of the following would you use if an element is to be removed from a specific index?

a del statement

What are the data items in a list called?

elements

In order to create a graph in Python, you need to include which? import matplotlib import pyplot import matplotlib.pyplot import pyplot import matplotlib

import matplotlib.pyplot

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

insert

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

list( )

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

nested list

The primary difference between a tuple and a list is that

once a tuple is created, it cannot be changed

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

tuple

Which method or operator can be used to concatenate lists?

+

What is the first negative index in a list?

-1

A list cannot be passed as an argument to a function.

False

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

False

The index of the first element in a list is 1, the index of the second element is 2, and so forth.

False

The remove method removes all occurrences of an item from a list.

False

The sort method rearranges the elements of a list so they are in ascending or descending order.

False

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

What will be the output after the following code is executed? import matplotlib.pyplot as plt def main(): x_crd = [0, 1 , 2, 3, 4, 5] y_crd = [2, 4, 5, 2] plt.plot(x_crd, y_crd) main()

Nothing; the number of x-coordinates do not match the number of y-coordinates.

What is an advantage of using a tuple rather than a list?

Processing a tuple is faster than processing a list.

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

Invalid indexes do not cause slicing expressions to raise an exception.

True

Lists are dynamic data structures such that items may be added to them or removed from them.

True


Conjuntos de estudio relacionados

Radiological Recognition and Safety : 5.7.1 - 5.7.2

View Set