Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer for learning journal #7 # name : [animal type, age, sex] animal_shellter = { Teddy: [dog,4,male], Elvis: [dog,1,male], Sheyla: [dog,5,female], Topic: [hamster,3,male], Kuzya: [cat,10,male],

Answer for learning journal #7

# name : [animal type, age, sex]

animal_shellter = {

"Teddy": ["dog",4,"male"],

"Elvis": ["dog",1,"male"],

"Sheyla": ["dog",5,"female"],

"Topic": ["hamster",3,"male"],

"Kuzya": ["cat",10,"male"],

"Misi": ["cat",8,"female"], }

print(animal_shellter)

print("")

def invert(d):

inverse = dict()

for key in d:

val = d[key]

for item in val:

if item not in inverse:

inverse[item] = [key]

else:

inverse[item].append(key)

return inverse

inverted_shellter = invert(animal_shellter)

print(inverted_shellter)

The Inverted dictionary is very useful becasue It give data for this problem.

NOW, here is the question:

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:

  • How to format each dictionary item as a text string in the input file.
  • How to covert each input string into a dictionary item.
  • How to format each item of your inverted dictionary as a text string in the output file.

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.

Include the following in your Learning Journal submission:

  • The input file for your original dictionary (with at least six items).
  • The Python program to read from a file, invert the dictionary, and write to a different file.
  • The output file for your inverted dictionary.
  • A description of how you chose to encode the original dictionary and the inverted dictionary in text files.

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 Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago