Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 cubes = { x: x * * 3 for x in range ( 5 ) } What code is equivalent to this dictionary

QUESTION 1
cubes ={x: x**3 for x in range(5)}
What code is equivalent to this dictionary comprehension?
cubes ={}
for x in range(5):
cubes.append(x: x **3)
cubes ={}
for x in range(5):
cubes[x]= x **3
cubes ={}
for x in range(5):
cubes.insert(x, x **3)
cubes ={}
for x in range(5):
cubes[x: x **3]
10 points
QUESTION 2
What is the process used to convert an object to a stream of bytes that can be saved in a file?
dumping
streaming
writing
pickling
10 points
QUESTION 3
What mode do you use with the open function to open a binary file for writing?
wb
b
bw
binarywrite
10 points
QUESTION 4
Which method would you use to get all the elements in a dictionary returned as a list of tuples?
list
items
keys
pop
10 points
QUESTION 5
Which answer pair will correctly complete this sentence:
To read an object from a file, you use the _______ funciton of the _______ module.
get, object
dump, pickle
read, object
load, pickle
10 points
QUESTION 6
squ_dict ={}
for x in range(10):
if x %2==0:
squ_dict[x]= x **2
What is the equivalent dictionary comprehension of the above code?
squ_dict ={if x %2==0(x: x**2) for x in range(10)}
squ_dict ={for x in range(10) if x %2==0 x: x**2}
squ_dict ={x: x**2 for x in range(10) if x %2==0}
squ_dict ={for x in range(10) x: x**2 if x %2==0}
10 points
QUESTION 7
When the following code executes, what values will be in the stocks2 dictionary?
stocks1={'GOOGL':2708, 'AAPL':147,'MSFT':288}
stocks2={'IBM':143,'HPQ':29,'MSFT':288}
stocks1|= stocks2
{'GOOGL':2708, 'AAPL':147,'MSFT':288, 'IBM':143,'HPQ':29}
{'GOOGL':2708, 'AAPL':147,'MSFT':288,'MSFT':288, 'IBM':143,'HPQ':29}
{'IBM':143,'HPQ':29,'MSFT':288}
{'IBM':143,'HPQ':29}
10 points
QUESTION 8
What operator was introduced in Python 3.9 that performs a dictionary merge?
^
|
->
<-
10 points
QUESTION 9
The ________ method returns all of a dictionary's keys as a dictionary view.
10 points
QUESTION 10
stations ={89.7:'WCPE', 91.5:'UNCW', 92.3:'WKRR',92.5:'WYFL'}
How could you create a list of the values from stations and assign it to station_names?
station_names = list(stations.values())
station_names = stations.values()
station_names = stations.values_list()
station_names.list(stations)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

Identify traditional external recruitment methods.

Answered: 1 week ago

Question

Describe alternatives to recruitment.

Answered: 1 week ago