subject

1. Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following: A. How to format each dictionary item as a text string in the input file.
B. How to covert each input string into a dictionary item.
C. How to format each item of your inverted dictionary as a text string in the output file.
D. Create an input file with your original three-or-more items and add at least three new items, for a total of at least six items.
2. Copy your program from Part 1 and modify it to do the following:
A. Read the output file from Part 1 and create a dictionary from it (the inverted dictionary from Part 1).
B. Invert that dictionary.
C. Write the re-inverted dictionary to an output file.
D. It will be interesting to see if your original dictionary is reversible. If you invert it twice, do you get the original dictionary back?
Include the following in your Learning Journal submission:
The input file for your original dictionary (with at least six items).
The Python program for Part 1.
The output file for your inverted dictionary, which is also the input file for Part 2.
The Python program for Part 2.
The output file for your twice-inverted dictionary.
A description of any differences between your program for Part 1 and your program for Part 2.
A description of any differences between the original input file and the final twice-inverted output file.
(This was the code from Learning Journal from Unit 7 & it's Output)
def invert_dict(d):
inverse = dict()
for key in d:
values = d[key]
for value in values:
if value not in inverse:
inverse[value] = [key]
else:
inverse[value].append(key)
return inverse
d = {
"k1": ["v1", "v2"],
"k2": ["v3", "v2"],
"k3": ["v4", "v7"]
}
print("Original dictionary: " + str(d))
print("Inverted dictionary: " + str(invert_dict(d)))

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:30
What are compression artifacts? 1) visible defects in the picture caused by the nature of the compression algorithm. 2) numbers that tell a web server how much to compress a picture for faster transmission. 3) invisible defects in the picture preserved by lossless compression. 4) numbers that tell a photo editing program how much to compress a picture for faster transmission.
Answers: 3
question
Computers and Technology, 22.06.2019 10:40
"it security policy enforcement and monitoring" respond to the following: describe how monitoring worker activities can increase the security within organizations. describe the rationale that managers should use to determine the degree of monitoring that the organization should conduct. explain the extent to which you believe an organization has the right to monitor user actions and traffic. determine the actions organizations can take to mitigate the potential issues associated with monitoring user actions and traffic.
Answers: 3
question
Computers and Technology, 22.06.2019 16:20
Consider the following statements, then select one of the answers below: the signal() function shown below registers "sig_handler()" as the signal handler function for the sigkill signal, without the complexity of using when the sigkill signal is sent to a process running this code, by a user typing "kill -kill ", where the correct process id is used for to target the process, sig_handler() will be executed.
Answers: 1
question
Computers and Technology, 23.06.2019 09:10
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
You know the right answer?
1. Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write t...
Questions
question
History, 09.01.2021 21:10
question
Mathematics, 09.01.2021 21:10
question
Social Studies, 09.01.2021 21:10
question
Social Studies, 09.01.2021 21:10
question
Arts, 09.01.2021 21:20
question
Mathematics, 09.01.2021 21:20
question
Mathematics, 09.01.2021 21:20
Questions on the website: 13722367