Ch 9

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the number of the first index in a dictionary?

Dictionaries are not indexed by number.

Sets are created using curly braces { }.

False

Sets are immutable.

False

The elements in a dictionary are stored in ascending order, by the keys of the key-value pairs.

False

The union of two sets is a set that contains only the elements that appear in both sets.

False

What does the get method do if the specified key is not found in the dictionary?

It returns a default value.

What will be the result of the following code? ages = {'Aaron' : 6, 'Kelly' : 3, 'Abigail' : 1 } value = ages['Brianna']

KeyError

Which of the following does not apply to sets?

The elements are in pairs.

A dictionary can include the same value several times but cannot include the same key several times.

True

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError exception is raised.

True

The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2.

True

The issubset() method can be used to determine whether set1 is a subset of set2.

True

The set remove and discard methods behave differently only when a specified item is not found in the set.

True

You would typically use a for loop to iterate over the elements in a set.

True

In order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the ________ operator.

in

Which method would you use to get all the elements in a dictionary returned as a list of tuples?

items

In a dictionary, you use a(n) ________ to locate a specific value.

key

Which would you use to get the number of elements in a dictionary?

len

What is the process used to convert an object to a stream of bytes that can be saved in a file?

pickling

Which method would you use to get the value associated with a specific key and remove that key-value pair from the dictionary?

pop

What is the correct structure to create a dictionary of months where each month will be accessed by its month number (for example, January is month 1, April is month 4)?

{ 1 : 'January', 2 : 'February', ... 12 : 'December' }

1. What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.) cities = {'GA' : 'Atlanta', 'NY' : 'Albany', 'CA' : 'San Diego'} if 'CA' in cities: del cities['CA'] cities['CA'] = 'Sacramento' print(cities)

{'CA': 'Sacramento', 'NY': 'Albany', 'GA': 'Atlanta'}

What will be displayed after the following code executes? (Note: the order of the display of entries in a dictionary are not in a specific order.) cities = {'Ga':'Atl','NY':'Alb','CA':'San D'} if 'FL' in cities: del cities['FL'] cities['FL']='Tallah' print(cities)

{'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}


संबंधित स्टडी सेट्स

Identifying Parts & Simplifying Algebraic Expressions (or Polynomials) WITH EXPLANATIONS!

View Set

Round 3 Review- Reconstruction Finance Corporation

View Set

California Real Estate Chapter 4

View Set

Survey of Recording Technology Comprehensive Study Guide

View Set

Push and Pull Factors of New World Migration to America

View Set

care and prevention: in class quiz on the knee

View Set

4.1 to 4.3: AP Human Geography Quizlet (Modules 25-27)

View Set