6.5.1 Creating and Altering Data Structures Quiz

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:13 PM on 3/16/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

15 Terms

1
New cards

Given the following list:
my_list = ["s", "Z", "e", "c", "c", "e", "r", "h", "e", "p", "t"]
which program below would give the following output:
s
e
c
r
e
t

for index in my_list:
if index % 2 == 0:
print(my_list[index])

for index in range(my_list):
if index % 2 == 0:
print(my_list[index])

for index in len(my_list):
if index % 2 == 0:
print(my_list[index])

for index in range(len(my_list)):
if index % 2 == 0:
print(my_list[index])

for index in range(len(my_list)):
if index % 2 == 0:
print(my_list[index])

2
New cards

Which values entered into 'my_list' would print a value of '-1' after the program has run?
my_list = [...]
num = 0
for thing in my_list:
num = num - thing
print(num)

5, -10, 6

-10, -5, 6

-5, 10, 6

-5, 0, 10, 6

5, -10, 6

3
New cards

Which of the following programs would produce the following output:
1. honey
2. bread
3. jelly
4. plates

my_list = ["honey", "bread", "jelly", "plates"]
for index in range(len(my_list)):
print(str(index) + ". " + my_list)

my_list = ["honey", "bread", "jelly", "plates"]
for index in range(len(my_list)):
print(str(index+1) + ". " + my_list[index])

my_list = ["honey", "bread", "jelly", "plates"]
for index in my_list:
print(str(index+1) + ". " + my_list[index])

my_list = ["honey", "bread", "jelly", "plates"]
for index in len(my_list):
print(str(index) + ". " + my_list[index])

my_list = ["honey", "bread", "jelly", "plates"]
for index in range(len(my_list)):
print(str(index+1) + ". " + my_list[index])

4
New cards

Which of the following programs would alter my_list to consist of the following:
['red', 'green', 'blue', 'orange', 'yellow']

my_list = ['red', 'green', 'blue', 'orange']
my_list.append('yellow')

my_list = ['red', 'green', 'blue', 'orange']
my_list.extend('yellow')

my_list = ['red', 'green', 'blue', 'orange']
my_list.replace('yellow')

my_list = ['red', 'green', 'blue', 'orange']
my_list.add('yellow')

my_list = ['red', 'green', 'blue', 'orange']
my_list.append('yellow')

5
New cards

What will be the output of the following program?
my_list = [1, 2, 3, 4]
num = 5
for index in range(len(my_list)):
my_list.append(num + index)
print(my_list)

[1, 2, 3, 4, 5, 6, 7, 8]

6
New cards

What kind of data structure is user_data in the following declaration?
user_data = ("TJ", 24, "artLover123")

Tuple

7
New cards

What kind of data structure is user_data in the following declaration?
user_data = ["TJ", 24, "artLover123"]

List

8
New cards

Which of the following lines of code will cause an error?
Use the following definition of ages:
ages = (12, 5, 8)

ages = ages + (1, 3, 5)

print(ages[2])

ages = ages[2:]

ages[0] = 3

ages[0] = 3

9
New cards

What does this code snippet print?
fruit = ["b", "n", "n"]
print("a".join(fruit))

bnn

ba na na

banan

banana

banan

10
New cards

What is the value of num after this code runs?
shapes = ["triangle", "square", "hexagon", "circle", "pentagon"]
num = len(shapes)

5

11
New cards

What does this program print?
sentence = "My favorite animal is a dog or chipmunk"
sentence_list = sentence.split()
sentence_list[-3] = "penguin"
sentence = " ".join(sentence_list)
print(sentence)

My favorite animal is a penguin or chipmunk

12
New cards

Which of the following data structures is immutable?
Tuple
List
Dictionary
2d List

Tuple

13
New cards

What does this program print?

heights = [65, 56, 67, 48, 64]
heights.sort()
heights.extend([60, 61, 62])
heights.remove(67)
print(heights)

[48, 56, 64, 65, [60, 61, 62]]

[48, 56, 60, 61, 62, 64, 65]

[48, 56, 64, 65, 60, 61, 62]

The program will error.

[48, 56, 64, 65, 60, 61, 62]

14
New cards

How many times does this program print That's a large class!?
num_students = [23, 21, 33, 35, 24, 35] for num in num_students: if num > 23: print("That's a large class!")

4

15
New cards

What would the following program print to the screen when run?
my_list = [7, 0, 0, "d", "n", "o", "B"]
my_list.reverse()
for thing in my_list:
print(thing)

B
o
n
d
0
0
7

Explore top notes

note
AP Psychology - The Senses
Updated 1280d ago
0.0(0)
note
AP World History Unit 6: 1750-1900
Updated 1255d ago
0.0(0)
note
Biology Semester 2 Study Guide
Updated 537d ago
0.0(0)
note
WHAP - Unit 2 Review
Updated 535d ago
0.0(0)
note
BIOMED 1.1 TEST
Updated 1200d ago
0.0(0)
note
Health Psychology (IB)
Updated 826d ago
0.0(0)
note
Pueblo uprising of 1680
Updated 1185d ago
0.0(0)
note
AP Psychology - The Senses
Updated 1280d ago
0.0(0)
note
AP World History Unit 6: 1750-1900
Updated 1255d ago
0.0(0)
note
Biology Semester 2 Study Guide
Updated 537d ago
0.0(0)
note
WHAP - Unit 2 Review
Updated 535d ago
0.0(0)
note
BIOMED 1.1 TEST
Updated 1200d ago
0.0(0)
note
Health Psychology (IB)
Updated 826d ago
0.0(0)
note
Pueblo uprising of 1680
Updated 1185d ago
0.0(0)

Explore top flashcards

flashcards
Asi Se Dice: Level 3 Chapter 1
41
Updated 1234d ago
0.0(0)
flashcards
Ohio Constitution Quiz
21
Updated 1180d ago
0.0(0)
flashcards
Top 200 Drugs
600
Updated 930d ago
0.0(0)
flashcards
Allemand
156
Updated 883d ago
0.0(0)
flashcards
Cognition 2
60
Updated 1095d ago
0.0(0)
flashcards
Anatomy Chapter 14 Quiz #3
26
Updated 27d ago
0.0(0)
flashcards
Asi Se Dice: Level 3 Chapter 1
41
Updated 1234d ago
0.0(0)
flashcards
Ohio Constitution Quiz
21
Updated 1180d ago
0.0(0)
flashcards
Top 200 Drugs
600
Updated 930d ago
0.0(0)
flashcards
Allemand
156
Updated 883d ago
0.0(0)
flashcards
Cognition 2
60
Updated 1095d ago
0.0(0)
flashcards
Anatomy Chapter 14 Quiz #3
26
Updated 27d ago
0.0(0)