Python Final CH 11

Ace your homework & exams now with Quizwiz!

When you iterate over a dictionary, what value is assigned to the loop variable?

Each key in the dictionary.

Which of the following is not a characteristic of a Python list?

It is immutable

What happens after execution of the following Python code? x = [1, 2, 3] y = 4 z = x + y

It produces an error.

Which of the following Python types are mutable?

List and dictionary

Which of the following list methods return a value?

No - append No - all of the answers are correct No - remove No - sort No - reverse Yes - none of the answers are correct

Which of the following types could not be used as value for a Python dictionary?

No - list No - bool Yes - They all could be used. No - string No - tuple

What is the value of y after the following Python code executes? x = 't' y = x in ['s', 't', 'u', 'v']

True

When should you use a Python list to store your data?

Yes -all of the answers are correct No -You find yourself using variables named item1, item2, item3, item4, etc. No - The data is related and you don't know how many items you will need to store. No - The data is related and you want to be able to process it using a loop instead of multiple statements processing each item individually.

What happens after execution of the following code? a = [1, 2, 3] b = [4, 5, 6] a.extend(b)

a contains [1, 2, 3, 4, 5, 6]

What happens after execution of the following code? a = [1, 2, 3] b = [4, 5, 6] a.append(b)

a contains [1, 2, 3, [4, 5, 6]

The method which adds a single item to the end of the list is:

append

Which of the following is not a Python list method?

get

Where mathematicians use subscripting, computer programmer use

indexing

What keyword parameter is used to send a key-function to the sort method?

key

Which of the following types could not be used as key for a Python dictionary?

list

The items dictionary method returns a(n)

sequence of tuples

Which of the following is not dictionary method?

sort

Which of the following expressions correctly tests if x is even?

x % 2 == 0


Related study sets

Government Unit 1 Lesson 2 Part 2

View Set

Insights 8 Glossary: Multicultural issues

View Set

Macroeconomics 2.01: The Circular Flow and GDP

View Set

MGW1010 Week 6 Managing Organisational Design

View Set

The 12 Stages of The Hero's Journey

View Set

A&E EXAM 1: TEST BANK PRACTICE QUESTIONS

View Set