Question
q1- If x is a dictionary, which of the following code snippets will add a new key-value pair to x, with a key of height
q1- If x is a dictionary, which of the following code snippets will add a new key-value pair to x, with a key of "height" and a value of 60? Group of answer choices
x[60] = "height"
x["height"] = 60
x.add("height", 60)
x.update("height", 60)
x[height] = 60
None of these
q2-
Describe the following data structure:
[ {"color": "red", "number": 17}, {"color": "orange", "number": 3} ]
Group of answer choices
A dictionary with strings as keys and a mixture of strings and numbers as values
A list of strings and numbers
A dictionary of lists
A list of dictionaries
None of these
q3-
Which of the following code snippets will print a list of all unique colors in the dataset? Use this starter code:
data = [ {"color": "blue", "number": 64}, {"color": "green", "number": 710}, {"color": "red", "number": 17}, {"color": "orange", "number": 110}, {"color": "green", "number": 49}, {"color": "yellow", "number": 63} ]
Group of answer choices
colors = [] for element in data: colors.append(element["color"]) print(colors, unique=True)
print(data["color"].unique())
None of these
print(data.select_unique("color"))
colors = [] for element in data: colors.append(element["color"]) print(colors)
print(set(data["color"]))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started