Question: In Numpy Please create the following: This code on Chegg is wrong for Q 5 and Q 6 only! See Below. Please correct! I submit

In Numpy Please create the following:
This code on Chegg is wrong for Q5 and Q6 only! See Below. Please correct!
I submit these questions to be answered and someone on Chegg attempted to answer the questions and responded by asking, Sure, please provide the key and value you'd like to include in the dictionary called `q1`. The keys and values are below the question for q1. You will notice keys and under keys you will see a column containing the words One, Two, Three, and Four. Under values you will see a column with A, B, C and D. Because there are no formatting options it is hard separate things on Chegg. It is pretty much the same format throughout the rest of the assignment. I am going to provide the answers/code for everything that is correct. Q1-Q4 & Q7. I only need Q5&Q6.
Create a dictionary called q1 that contains the following keys and values:
import numpy as np
q1={'One': 'A', 'Two': 'B', 'Three': 'C', 'Four': 'D'}
keys values
One A
Two B
Three C
Four D
Index q1 to obtain "C". Assign it to Q1.
Q1= q1['Three']
Create a dictionary called Q2 that contains the following keys and values:
Q2={'Five': 'E', 'Six': 'F'}
keys values
Five E
Six F
Update the dictionary to also include:
Q2['Seven']='G'
keys values
Seven G
Create a dictionary called Q3 that contains the following keys and values:
Q3={'Eight': 'H'}
keys values
Eight H
Delete the entry within this dictionary.
del Q3['Eight']
Create a dictionary called Q4 that contains the following keys and values:
Q4={'Nine': 'I', 'Ten': 'J'}
keys values
Nine I
Ten J
Update the dictionary for the given key
Q4['Ten']='K'
keys values
Ten K
Q5 and Q6 are Wrong Please provide correct code in Numpy for Jupyter Notebook
Define a function Q5 that prints all the values in q1. Output should look like the
A
B
C
D
Define a function Q6 that prints all the keys in q1. Output should look like the following:
One
Two
Three
Four
These are all wrong. The output was the same.
def Q5(dict):
for value in dict.values():
print(value)
Q5(q1)
def Q6(dict):
for key in dict.keys():
print(key, end="")
Q6(q1)
# Define function Q5
def Q5(dictionary):
for value in dictionary.values():
print(value)
# Define function Q6
def Q6(dictionary):
for key in dictionary.keys():
print(key)
This is what the actual out put looked like.
Define a nested dictionary that contains the following information (Fruit and Color should
be nested within the Favorites):
Fruit Color
Least Favorite Grape Purple
Medium Favorite Apple Red
Most Favorite Banana Yellow
Assign it to Q7.
Q7={
'Least Favorite': {'Fruit': 'Grape', 'Color': 'Purple'},
'Medium Favorite': {'Fruit': 'Apple', 'Color': 'Red'},
'Most Favorite': {'Fruit': 'Banana', 'Color': 'Yellow'},
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!