Original dictionary back

Assignment Help Business Management
Reference no: EM132272676

Part 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:

  • 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.

Part 2

Copy your program from Part 1 and modify it to do the following:

  • Read the output file from Part 1 and create a dictionary from it (the inverted dictionary from Part 1).
  • Invert that dictionary.
  • Write the re-inverted dictionary to an output file.

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.

Reference:

Learning Journal Unit 7

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.

# 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.

I'm able to pull out the text file but I'm having trouble doing the assingment:

import os

cwd = os.getcwd()

fin = open('words.txt')

for line in fin:

   word = line.strip()

   print(word)

Reference no: EM132272676

Questions Cloud

How is the equity growth rate computed : Why is interest expense ignored when computing return on net operating assets (RNOA)? How is the equity growth rate computed? What does it measure?
Skills are required to become master contract negotiator : Discuss which skills are required to become a Master Contract Negotiator? Which skills do you currently use when you are performing negotiations?
Another program to parse and execute the code : Interpreted languages rely on another program to parse and execute the code, whereas compiled languages rely on a compiler, another program
Write briefly about the sections of statement of cash flows : On January 24th, 2018, SABIC's Board of Directors declared to distribute 6 SR per share as cash dividends. SABIC has 3,000,000 common shares outstanding.
Original dictionary back : It will be interesting to see if your original dictionary is reversible. If you invert it twice, do you get the original dictionary back?
The renaissance and the reformation in german-speaking lands : Choose some topic related to art and the period of the Renaissance and the Reformation in German-speaking lands.
Competitive strengths compared to its key rivals : What are Chipotles Competitive strengths compared to its key rivals. Details.
What you can contribute to the organization : IBIS World and BizStats have estimates of cost of goods sold and some other categories of operating expenses. Information about contribution margins.
Health services-insurance company cigna health care : Analyze a consumer research-related problem and summarize key points for the Health Services/ Insurance Company Cigna Health Care.

Reviews

Write a Review

Business Management Questions & Answers

  Meeting yesterday with chief administrator joe wellborn

After meeting yesterday with chief administrator Joe Wellborn, it has been decided that the litigation issues with one (1) of the patients

  Differentiating rational and irrational decision making

Using the Internet on the differences between rational and irrational decision making.

  Cost benefit analysis and us health care

Cost Benefit Analysis and US Health Care

  Develop five perspectives of a potential balanced scorecard

develop three to five perspectives of a potential balanced scorecard and four to six measures for each perspective. Do you think the balanced scorecard will provide the information the brothers are seeking?

  Changing the tld of a well-known website

Is it legal to grab up domains and park them? Is it ethical? What about changing the TLD of a well-known website

  Dhs and points of dod involvement

What is meant by a bottom-up approach? Shouldn't those with more knowledge and authority be in command?

  Graham-leviss article and burgelman working paper

Using the Graham-Leviss article and Burgelman Working Paper (You are asked to read only pages 4-7, 13-19, and 19-21.) as a starting point

  What are the strategic implications of that shift

What determines a firm's ability to prosper? What are the strategic implications of that shift? When and how should the firm shift to the new technology

  Greener and more profitable supply chain

Read the Forbes article, "3 Lessons for a Greener and More Profitable Supply Chain." Based on the content presented in the article, what is meant by a green supply chain? Identify in 200 -250 words two techniques or processes that you could potent..

  Avon call on foreign markets

Review the chapter 16 closing case: Avon Call on Foreign Markets.  Fully answer all questions at the end of the case: The chapter describes different marketing orientations. Discuss the applicability of each to Avon's international operations. Why i..

  Considering buying another smaller firm

The company that you are working for is considering buying another smaller firm. However, there is some business analysis needed for your.

  International groups with differing cultures and languages

How does the two non-verbal communication (Facial gestures and voice) play a role between international groups with differing cultures and languages?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd