subject

Create a Python dictionary where the value is a list. The key can be whatever type you want.
Design the dictionary so that it could be useful for something meaningful to you. Create at least three different items in it. Invent the dictionary yourself. Do not copy the design or items from some other source.
Next consider the invert_dict function from Section 11.5 of your textbook. (https://www. dropbox. com/s/gg6szmo42tfezl5/Think%20Pytho n%202e. pdf?dl=0)
# From Section 11.5 of:
# Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.
def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
else:
inverse[val].append(key)
return inverse
Modify this function so that it can invert your dictionary. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary.
Run your modified invert_dict function on your dictionary. Print the original dictionary and the inverted one.
Include your Python program and the output in your Learning Journal submission.
Describe what is useful about your dictionary. Then describe whether the inverted dictionary is useful or meaningful, and why.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 16:00, kebo63
Page orientation can be either landscape or
Answers: 1
image
Computers and Technology, 21.06.2019 17:30, jamarian101
Think about the poem "old ironsides." drag the subject of the poem to the subject box and the theme to the theme box. then decide whether each excerpt from the poem supports the subject or the theme.
Answers: 3
image
Computers and Technology, 22.06.2019 21:00, daniella0123
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
image
Computers and Technology, 23.06.2019 06:00, Disd112984
Which statement is true of web-based social media? a. they allow consumers to interact with and update content. b. they cannot be updated easily, as compared to print media. c. they are expensive to produce and maintain, as compared to print and television. d. they can exist independent of the internet.
Answers: 1
You know the right answer?
Create a Python dictionary where the value is a list. The key can be whatever type you want.
...

Questions in other subjects:

Konu
Mathematics, 05.10.2019 00:40