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

  What in the clawson and northouse texts would support

What does he mean by this, and, what in the Clawson and Northouse texts would support (or conflict with) why that is the case.

  Managers leaders and governing boardswhat are challenges

managers leaders and governing boardswhat are challenges that managers leaders and governing boards have to deal with

  Consequences of in group and out group categorization

So, what are the consequences of in group and outgroup categorization? How does this categorization affect a person's behavior in a group or team?

  Carry out the management function at nbb

How do Kim and Jeff carry out the management function at NBB? Describe ways in which the founders assumed deci- sional roles in their work. How would you describe New Belgium Brewing's or- ganizational culture?

  Explain why were these particular factors selected

Explain Why were these particular factors selected? Why are they important in accessing the success of the company? (2-3 pages)

  Transactional and laissez-faire leadership styles

In what ways would transactional and laissez-faire leadership styles be ineffective in encouraging organizational commitment?

  Vehicles class to instantiate three objects making

Write a Use Vehicles class to instantiate three objects making use of proper overloaded class constructors: one object of the Vehicle class, one object of the PassengerCar class and one object of the Truck class. When doing so, accept the user inp..

  Does method have a societal marketing orientation

Does Method have a societal marketing orientation, or is it just a marketoriented company that integrates a number of environmental practices into its operations? Explain.

  United states court of appeals for the first circuit

A group of winemakers from California and several Massachusetts residents challenged a Massachusetts law that distinguishes how large wineries

  Impact on mnc organization structure

In what way do the concept of formalization, specialization , and centralization have an impact on MNC organization structure? In your answer, use a well known firm such as IBM or Ford to illustrate the practical expressions of these three charact..

  Deposits in a savings account

You need to accumulate $98,768 for your son's education. You have decided to place equal year-end deposits in a savings account for the next 14 years.

  Evolutionary trends in organizational behavior

Evolutionary trends in organizational behavior - Assess the evolutionary trends in organizational behavior how they might impact organizations over the next 10 years?

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