Py4e: Chapter 8

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What does the following Python code print out? a = [1, 2, 3] b = [4, 5, 6] c = a + b print(len(c))

6

What type of data is produced when you call the range() function? x = range(5)

A list of integers

How are "collection" variables different from normal variables?

Collection variables can store multiple values in a single variable

What will the following Python code print out? friends = [ 'Joseph', 'Glenn', 'Sally' ] friends.sort() print(friends[0])

Glenn

What would the following Python code print out? fruit = 'Banana' fruit[0] = 'b' print(fruit)

Nothing would print - the program fails with a traceback

What list method adds a new item to the end of an existing list?

append()

What are the Python keywords used to construct a loop to iterate through a list?

for / in

For the following list, how would you print out 'Sally'? friends = [ 'Joseph', 'Glenn', 'Sally' ]

print(friends[2])

Which of the following Python statements would print out the length of a list stored in the variable data?

print(len(data))

Which of the following slicing operations will produce the list [12, 3]? t = [9, 41, 12, 3, 74, 15]

t[2:4]


Kaugnay na mga set ng pag-aaral

CHAPTER 54 MUSIC QUIZ, Chapter 53: MUS 110, Chapter 52: MUS 110, Music Test 2

View Set

BIOL252 PhysioEx 1: Ex 1 Cell Transport Mechanisms & Permeability

View Set

Financial Risk Management - Chapter 17

View Set

Sadlier Vocabulary Workshop - Level B - Unit 6 - Synonyms

View Set