Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON MULTIPLE CHOICE 1a) The ______ method returns all of a dictionarys keys and their associated values as a sequence of tuples. keys_values() values() items()

PYTHON MULTIPLE CHOICE 1a) The ______ method returns all of a dictionarys keys and their associated values as a sequence of tuples.

keys_values() 
values() 
items() 
get() 

1b) The ________ method returns the value associated with a specified key and removes that key-value pair from the dictionary.

pop() 
random() 
popitem() 
rand_pop() 

1c) Which statement correctly creates a set named colors that contains the 7 colors in a rainbow?

colors = ["red", "orange", "yellow" "green", "blue", "indigo", "violet"] 
colors = {red, orange, yellow, green, blue, indigo, violet} 
colors = [red, orange, yellow, green, blue, indigo, violet] 
colors = {"red", "orange", "yellow", "green", "blue", "indigo", "violet"} 

1d) Which of the following code segments prints red is a color of the rainbow when the set colors contains the string "red"?

if colors contains "red": print("red is a color of the rainbow") 
if "red" in colors: print("red is a color of the rainbow") 
if "red" not in colors: print("red is a color of the rainbow") 
if colors includes "red": print("red is a color of the rainbow") 

1e) How can you print all the elements in the set colors each on a separate line?

for i in range(len(colors)): print(colors[i]) 
for color in colors: print(color) 
print(colors) 
for i in range(0, len(colors)): print(colors[i]) 

1f) Which statement(s) below print the set colors in sorted order?

for i in range(len(colors)): print(colors[i]) 
for color in sorted(colors): print(color) 
for color in colors.sorted(): print(color) 
for i in range(len(colors)): print(sorted(colors[i])) 

1g) Given the following code snippet, which statement tests to see if all three sets are equal?

fruit = set(["apple", "banana", "grapes", "kiwi"]) fruit2 = set(["apple", "banana", "grapes", "kiwi"]) fruit3 = set(["apple", "banana", "pears", "kiwi"]) 
if fruit.equal(fruit2) and fruit.equal(fruit3): 
if fruit == fruit2 and fruit == fruit3: 
if fruit != fruit2 and fruit != fruit3: 
if fruit == fruit2 or fruit == fruit3: 

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_2

Step: 3

blur-text-image_3

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions