Python ch 8

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

What does the following code print? time_of_day = ["morning", "afternoon", "evening"] for word in time_of_day: print "Good " + word

Good morning Good afternoon Good evening

Which of the following is the correct way to declare a tuple?

x = (1,2,3)

Which of the following is NOT true about tuples?

Tuples use parentheses to access individual elements, rather than square brackets.

Which of the following Python programs creates a list with the numbers 1 through 5?

my_list = [1, 2, 3, 4, 5]

Look at the following program: my_list = ["bananas", "oranges", "grapes", "pineapples", "apples"] # You pick the code that goes here... # ... # ... print my_list Pick the code that results in the following output: ['apples', 'bananas', 'grapes', 'oranges', 'pineapples']

my_list.sort()

Look at the following program: my_list = ["bananas", "oranges", "grapes", "pineapples", "apples"] # You pick the code that goes here... # ... # ... print my_list Pick the code that results in the following output: ['pineapples', 'oranges', 'grapes', 'apples']

my_list.sort() my_list.reverse() my_list.remove("bananas")

Which of the following code snippets will correctly convert a string to a list?

my_string = "hello" str_as_list = list(my_string)

What code below will print the following? Letter 1: T Letter 2: I Letter 3: m

name = "Tim" name_list = list(name) for index, value in enumerate(name_list): print "Letter " + str(index+1) + ": " + name_list[index]


Conjuntos de estudio relacionados

Commissioned Officers, Office & Army Structure

View Set

HESI A2 - Critical Thinking- Rationale

View Set

Chapter 15, Retirement and Estate Planning

View Set

Government Terms Federal Bureaucracy & Fiscal Policy

View Set

Chapter 15: Family Assessment and Interventions

View Set

Chapter 20: Family-Centered Palliative Care

View Set

7th Grade Math Vocabulary Epic Charter

View Set