COP1047C - Unit 6, Chapter 07

0.0(0)
studied byStudied by 2 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

flashcard set

Earn XP

Description and Tags

Chapter 7 Practice Exam for COP1047C Final Exam

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards

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)

if name == '__main__':

main()

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

2
New cards

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


a del statement

3
New cards

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

Processing a tuple is faster than processing a list.

4
New cards

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

nested list

5
New cards

In order to create a graph in Python, you need to include

import matplotlib.pyplot

6
New cards

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

tuple

7
New cards

What values will list2 contain after the following code executes?

list1 = [1, 10, 3, 6]

list2 = [item * 2 for item in list1 if item > 5]

[20, 12]

8
New cards

Which method or operator can be used to concatenate lists?

+

9
New cards

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]

10
New cards

This function in the random module returns a random element from a list.


choice

11
New cards

What is the first negative index in a list?

-1

12
New cards

What are the data items in a list called?

elements

13
New cards

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

insert

14
New cards

This function in the random module returns multiple, nonduplicated random elements from a list.

choices

15
New cards

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]

16
New cards

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

list

17
New cards

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]

18
New cards

The primary difference between a tuple and a list is that

once a tuple is created, it cannot be changed

19
New cards

What values will list2 contain after the following code executes?

list1 = [1, 2, 3]

list2 = [item + 1 for item in list1]

[2, 3, 4]

20
New cards

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]