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

  Caselet on michael porter’s value chain management

The assignment in management is a two part assignment dealing 1.Theory of function of management. 2. Operations and Controlling.

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. Due to increase in the preference for light beer drinkers, Chris Prangel wants to introduce light beer version in Mountain Man. An analysis into the la..

  Mountain man brewing company

Mountain Man Brewing, a family owned business where Chris Prangel, the son of the president joins. An analysis into the launch of Mountain Man Light over the present Mountain Man Lager.

  Analysis of the case using the doing ethics technique

Analysis of the case using the Doing Ethics Technique (DET). Analysis of the ethical issue(s) from the perspective of an ICT professional, using the ACS Code of  Conduct and properly relating clauses from the ACS Code of Conduct to the ethical issue.

  Affiliations and partnerships

Affiliations and partnerships are frequently used to reach a larger local audience? Which options stand to avail for the Hotel manager and what problems do these pose.

  Innovation-friendly regulations

What influence (if any) can organizations exercise to encourage ‘innovation-friendly' regulations?

  Effect of regional and corporate cultural issues

Present your findings as a group powerpoint with an audio file. In addition individually write up your own conclusions as to the effects of regional cultural issues on the corporate organisational culture of this multinational company as it conducts ..

  Structure of business plan

This assignment shows a structure of business plan. The task is to write a business plane about a Diet Shop.

  Identify the purposes of different types of organisations

Identify the purposes of different types of organisations.

  Entrepreneur case study for analysis

Entrepreneur Case Study for Analysis. Analyze Robin Wolaner's suitability to be an entrepreneur

  Forecasting and business analysis

This problem requires you to apply your cross-sectional analysis skills to a real cross-sectional data set with the goal of answering a specific research question.

  Educational instructional leadership

Prepare a major handout on the key principles of instructional leadership

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