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.

Answers

Answer 1

Answer:

Following are the code to this question:

import ast as a #import package ast

d1= {}#defining an empty dictionary  

def invert_dictionary(d1):#defining a method invert_dictionary

   i = dict()#defining variable i that hold dict method  

   for k in d1:#defining for loo to check dictionary value

       val = d1[k]#defining val variable to holds dictionary key values

       for val1 in val:#defining another for loop to hold value of dictionary and inverse it

           if val1 not in i:#defining if block to check value

               i[val1] = [k]#hold key value

           else:#defining else block

               i[val1].append(k)#add value in dictionary

   return i#return inverse value

with open("dict_items.txt", "r") as data:#use open method to add a list as a file

   dict_item = a.literal_eval(data.read())#defining a variable that covert item as a text string in the input file  

   '''covert input string into dictionary item'''

   e_val = input("Please enter a value")#defining variable e_val to input value

   dict_item['4']=str(e_val)#holding value in dictionary

   dict_item['5']='e'#holding value in dictionary

   dict_item['6']='f'#holding value in dictionary

   '''Invert the dictionary value '''

   invert_data =invert_dictionary(dict_item)#defining variable to holding method value

'''calculating the format of each item of inverted dictionary as a text string output file.'''

f_data = {i:str(j[0]) for i,j in inverted_data.items() }#defining f_data to hold coverted value

import json as j#import package

with open('out_put.txt', 'w') as file:#use open method to open file

   file.write(j.dumps(f_data))#add value

Explanation:

In the above-given code has four parts which can be defined as follows:

In the first part, a method invert_dictionary is defined that accepts a dictionary, and defines two for loops in which the second loop uses a conditional statement to convert the inverse form and return its value, and after inverse it use the open method to add a list as a file, and defining a variable that covert item as a text string in the input file.

In the second step, a variable e_val is declared for input value , and use the dict_item variable to holding dictionary  value, and call the method and hold its value.

In the third and fourth step it calculating the format of each item of inverted dictionary as a text string output file.


Related Questions

Universal Container wants to understand all of the configuration changes that have been made over the last 6 months. Which tool should an Administrator use to get this information

Answers

Answer:

Set up audit trail

Explanation:

The administrator should set up an audit trail in order to get this information.

An audit trail would give him the record of all the configuration changes that have been made in a file or a database in the last 6 months.

Audit trails can be manual or electronic. It provides history and also documentation support. It can authenticate security and also help to mitigate challenges.

Which of these are true? Check all that apply.

a. You can have many processes running for one program.
b. A program is a process that is executed. A process is a program that we can run.
c. A program is initially stored in RAM. A process is initially stored in the hard drive.
d. A program is an application that we can run. A process is a program that is executed.

Answers

Answer:

The following are true according to the process and the information which is  being implemented.

b. A program is a process that is executed. A process is a program that we can run.

c. A program is initially stored in RAM. A process is initially stored in the hard drive.

d. A program is an application that we can run. A process is a program that is executed.

Explanation:

Statements that are true as regards how programs and the information is  being implemented are;

A program is a process that is executed. A process is a program that we can run.A program is initially stored in RAM. A process is initially stored in the hard drive.A program is an application that we can run. A process is a program that is executed.

According to the question we are to discuss program and its implementation and how it is been run.

As a result of this we can see that program is an application that we can run. A process is a program that is executed.

Therefore, program is a process that is executed. A process is a program that we can run..

Learn more about program at;

https://brainly.com/question/16397886

The default for automatic replies in outlook is what?

Answers

Answer:

The default for automatic replies in outlook is turned off, so the user has to turn it on in order to use it.

Out.look is a program developed by Micro.soft for managing e-mails, being together with G.mail one of the most used worldwide. As in most of these programs, you can configure automatic responses in order to give a quick and generic response to certain types of messages (or even all). Now, this option is disabled by default, so the user must activate it through the configuration of the email box.

The default for automatic replies in Outlook is

disabled

It is best to

schedule  automatic replies.

Automatic replies may validate your

email  to spammers.

Automatic reply rules are for

conditional  settings like forwarding a message to a coworker.

What is the difference between a programming language and natural (every-day) language?

Answers

Natural languages are used for communication between people

draw internal architecture of computer​

Answers

Answer:

If this is good, let me know in the comments and I'll draw it

Explanation:

Fix the infinite loop so that it counts from 3 down to 1.public class Loop1{public static void main(String[] args){int x = 3;while (x > 0){System.out.println(x);}}}

Answers

Answer:

Include x-- right after the print statement

Explanation:

Given:

The above lines of code

Required

Edit to countdown from 3 to 1

The above code (as it is) prints 3 in infinite times. To make it countdown to 1, we simply include a decrement operation.

Initially, the value of x is 3: int x = 3;

And the condition is that the loop is to be repeated as long as x > 0

All we need to do is to include x-- right after the print statement.

This  operation will reduce the value of x on every iteration as long as the condition is true.

Hence, the complete code is:

public class Loop1{

   public static void main(String[] args){

       int x = 3;

       while (x > 0){

           System.out.println(x);

          x--;

       }}}

Which of these devices collects the most information on network activity?

a. Intrusion detection systems.
b. System Event Management systems.
c. Firewalls.
d. Packet sniffers.

Answers

Answer:

The devices collects the most information on network activity are:

d. Packet sniffers.

Explanation:

Generally, a packet sniffer is a monitoring device which examines streams of data packets that flow between computers on a network and the larger Internet.  One of the best packet sniffers is the Wireshark.  As a packet sniffer, the Wireshark is also an analysis tool.  It captures network traffic on local networks, storing the obtained data for offline analysis.

A corporate or government network that uses Internet tools, such as Web browsers, and
Internet protocols best defines

Answers

Answer: Intranet

Explanation:

The options include:

A. extranet.

B) social network.

C) intranet.

D) e-market.

A corporate or government network that uses Internet tools, such as Web browsers, and Internet protocols is referred to as intranet.

Social networks are social media sites that are used by people which allows them to stay connected with one another.

E-market is a form of marketing whereby goods and services are promoted or advertised through the use of the internet.

Therefore, the answer to he above question is intranet.

Can you sort by reading the string in reverse in python?

Answers

Explanation:

# Let our string is brainlycom

Main = "brainlycom"

# First we will print the original string.

print("The original string : " + str(Main))

#Now Reverse Sort a String

Reverse_Sort= ''.join(sorted(Main, reverse=True))

print("String after reverse sorting : " + str(Reverse_Sort))

After running the above code you will get the result:

The original string : brainlycom

String after reverse sorting : yronmlicba

Rita tried unsuccessfully to open a PDF file attachment in her Inbox by double-clicking the attachment in the Reading Pane. What is the most likely reason that the file would not open properly? The PDF attachment should have been right-clicked. PDFs are too large to be sent through most e-mail systems. An add-in for PDFs was not set up in the system. Outlook never accepts PDF files as attachments.

Answers

Answer:

3rd option

Explanation:

Buying a new computer for which of these reasons is most likely a sound
financial decision?
A. You liked the ad for it on TV.
B. You need it to do your homework.
O c. Your friend has one.
D. You were persuaded by a salesperson.

Answers

Answer:

b. you need it to do your homework

Explanation:

If you can answer theses ill give u a brainliest (i think thats how u spell it) but only if u get it right u will get one NOT A SCAM!!

Question: In which logical operator at least one condition has to be true?

O or

O None of the above

O not

O and

Question: In which logical operator both conditions must be true?

O and

O or

O not

O None of the above

Answers

Answer:

or / and

Explanation:

i took the quiz at unitek college

Answer:

1. or

2. and

Explanation:

How many passes will it take to find the four in the list 4,5,6,7,8,9,10

Answers

Answer:

1

Explanation:

Which is an example of a technology that has changed the safety of humans?
A) a bicycle

B) a window

C) a rope

D) a baseball bat

Answers

Answer:

B

Explanation:

because they have added more protection from breaking window to keep people safe such as if there were a lot of layers of city

how many usable host addresses are available for each subnet when 4 bits are borrowed from a class C IP address

Answers

Answer:

The answer is "14".

Explanation:

Let the IP address [tex]= 196.45.204.0[/tex]

When it borrowed 4 bits

[tex]\therefore\\\\ subnet = 28[/tex]

[tex]IP= \frac{196.45.204.0}{28}\\\\ 28 \to 11111111.11111111.11111111.11110000[/tex]

If the borrowed bits are left out then:

The Number of useable host addresses:

[tex]= {(2^4) - 2} \\\\ = 16-2\\\\ =14[/tex]

_______ is a standard protocol used for synchronous communication.

Answers

Answer:

TCP/IP

Explanation:

Synchronous communication possesses the clocks on easy transmission as well as receiving devices in a lot more significant ways.

So, synchronous communication usually permits more information to be disseminated over a circuit per unit time.

The standard protocol for this synchronous communication is TCP/IP.

What does a wireless LAN (WLAN) act as to a wired network?

a. Gateway
b. Bridge
c. Switch
d. Router

Answers

Answer:

The answer is option A "Gateway"

Explanation:

A wireless LAN (WLAN) connects at least two computers or devices using some wireless distribution technique (normally spread-spectrum or OFDM radio), and as a rule gives a connection through a gateway/modem to the more extensive Web. This gives clients the portability to move around through a local coverage and still be connected with the network.

Wireless LANs have gotten famous in the home because of simplicity of establishment, the expanding ubiquity of PC and hand-held PCs, and commonality, due the accessibility of (frequently free) wireless network on schools and in open organizations.

A WLAN, or wireless LAN, is a network that permits gadgets to connect and communicate wirelessly. Dissimilar to a traditional wired LAN, in which gadgets communicate over Ethernet links, devices on a WLAN connects by means of Wi-Fi. They can speak with different gadgets on the network a similar way they would on a wired network.

The essential contrast is the way the information is communicated. In a LAN, information is communicated over actual links or cables in a progression of Ethernet packets. In a WLAN, bundles are communicated over the air.

Question 57 Which type of application attack would include User denies performing an operation, attacker exploits an application without trace, and attacker covers her tracks

Answers

Answer:

Auditing and logging

Explanation:

Auditing and logging is a form of application threats and attacks that an application security is susceptible to. It involves a user denies performing an operation; attacker exploits an application without trace, and at the same time attacker covers his or her tracks.

To prevent this, an Auditing and logging countermeasure should be put in place of application security to guide against such aforelisted threats and attacks before its actual occurrence.

Therefore, in this case, the correct answer is "Auditing and logging."

Which are the steps in the process of creating a database

Answers

Answer:

Determine the purpose of your database. ...

Find and organize the information required. ...

Divide the information into tables. ...

Turn information items into columns. ...

Specify primary keys. ...

Set up the table relationships. ...

Refine your design. ...

Apply the normalization rules.

Answer:

identifying fieldnames in tables

defining data types for field names

Explanation:

sorry I'm late. future Plato users this is for you

What happens when a string doesn’t include the separator that’s specified in the parameter of the split() method?

Answers

Answer:

Nothing

Explanation:

If a seperator value is provided as an argument within the split() method and the string does not include that value then the string will remain the same and will not be split. If no value is provided as an argument within the split() method, then the string that the method is being applied to will automatically be split in every space character (" ") that exists within it. This is the default value of split() when no argument is passed to it.

a term to describe article that can be displayed in their entirety as opposed to abstract and reference only?​

Answers

Answer:

would it be term and tequnique?

Explanation:

oooooooo

What are the top ten famous games in the U.S.

Why? cause I wanna know :D

Answers

Minecraft

Fortnite

Rob.lox

GTA V

Rocket league

League of legends

Mario bros

GTA

Among us

Call Of Duty

he IT director asks you to verify that the organization's virtualization technology is implemented securely. What should you do

Answers

Answer:

Check that virtual machines have always had the upcoming services packs as well as patches set up.

Explanation:

Among the very most essential preventive measures, you could even begin taking would be to download the application security relies on upon and splotches. The whole principle applies to routine OS, implementations as well as virtualization software. It would not be appropriate for software applications to have been multihomed even though it will not seem to significantly boost their protection.Penetration testing is being managed to complete before the implementation of virtual servers. Subnetting isn't necessary for virtual servers, and while it may improve safety. It must be factored into the equation during most of the capacity building phase.

Consider a file/directory with the following info:

-rwxr-x--x 1 milk milk 1858 May 1 16:29 abc

Which of the following statement(s) is/are true for the file/directory? Pick ONE OR MORE options

a. abc is a directory.
b. The group the owner belongs to can read and execute abc.
c. All other users can execute abc.
d. The owner can not execute abc.

Answers

Answer:

The statement that is true for the file/directory is:

a. abc is a directory.

Explanation:

A file directory is a computer filing system with cataloging and referencing structure to computer files and other directories.  Also known as folders or drawers, directories are like the workbench or traditional office filing cabinet.  Information is stored in files, which are then stored in directories (folders). Directories can also store other directories to form a directory tree.

"abc" is a directory. A further explanation is below.

A file directory would be a type of computer organizing system that provides cataloging and reference architecture for computer records as well as other directories.Files have been used to hold knowledge, which would be subsequently organized into directories. Additional directories could be stored in directories just to construct its hierarchy.

Thus the above approach is right.

Learn more about the directory here:

https://brainly.com/question/7007432

joe Hubb does not have a secure workplace to do payroll and store confidential records in the store. He uses a space in his home exclusively for this purpose and documents the use thoroughly. What form is used to calculate his office in the home deduction

Answers

Answer:

Joe Hubb can use Form 8829 to calculate his office in the home deduction.

Explanation:

Based on the scenario, Joe is a self-employed taxpayer.  Self-employed taxpayers who are filing IRS Schedule C, Profit or Loss from Business (as Sole Proprietorship) calculate their 'Expenses for Business Use of Home' on Form 8829.  The expenses that are deductible include costs of electricity, heating, maintenance, cleaning supplies, and minor repairs, but only the business-use portions.

The illegal copying of program​

Answers

Answer:Software piracy

Explanation:

Which of the following variable names follows the rules for naming variables?
A. snack $
B. favorite_snack
C. lunch time
D. 15 minute snack

Answers

D. 15 minute snack
Sorry if wrong

Complete the getOdds method so it returns a new ArrayList of Integers containing all odd Integers from the parameter ArrayList vals in the order they originally appeared. The contents of vals should not change. For example if an ArrayList containing the Integers 2, 5, 8, 6, 7, 3, 12 in that order is passed as a parameter to getOdds, it should return an ArrayList containing the Integers 5, 7, 3 in that order. Write your getOdds method in the U7_L2_Activity_Three class. Use the runner class to test your method but do not add a main method to your U7_L2_Activity_Three.java file or your code will not be scored correctly.

Answers

Answer:

Answered below

Explanation:

//Program is written in Java programming language.

public ArrayList<Integer> getOdds( ArrayList<Integer> list){

// Create variables to hold the new list and the //indexes.

int i;

ArrayList<Integer> oddList = new ArrayList<Integer>()

//Loop over the list and add every odd element // to the new list

for ( i = 0; i < list.length; I++){

if ( list[i] % 2 != 0){

oddsList.add(list[i])

}

}

return oddList;

}

The ______________ shows that you have fully researched the topic and gives you a chance to prove your claim.

a
Conclusion
b
Introduction
c
Counterclaim
d
Topic Sentence
Question 9 (5 points)

Answers

Answer:

D. Topic Sentence

Explanation:

Vanessa is a set designer. She is working on a period film set in Egypt. She has selected several items for a scene in a palace. She visits a library and a museum in Cairo to check the authenticity of the items. What responsibility is Vanessa undertaking?

Answers

Answer:

the responsibility of cultural and historical accuracy checking

Explanation:

Vanessa seems to be undertaking the responsibility of cultural and historical accuracy checking. By visiting the library and museum, Vanessa is researching historical data in order to make sure that the items that she has selected match the same type of items that Individuals living in Ancient Egypt times would use as well. This provides both historical and cultural accuracy to the film by representing The citizens of Ancient Egypt as they were in that time.

C - researching

PLATO

Other Questions
Proportion isa. the all-encompassing reproduction of a person or thing.b. the relative size of an object as compared to another, or as compared to the other elementsin the piece.the arrangement of visual elements in a piece, which helps to create understanding andconvey the artist's message.the arrangement of elements in order to create equilibrium and a piece that is aestheticallypleasing.C.d.Please select the best answer from the choices providedABCD Bob sets the price of the plants according to their height in inches. A plant that is 9.5 inches high costs $2.28 in his store.What is the price per inch of a plant? 0.24 What is the price of a plant that is 5.5 inches high? Show your calculation. Rewrite the expression in the form 3".3.3.3.3.3.33.3.3.3 There is a rope running from thetop of a flagpole to a hook in theground. The flagpole is 6 metershigh, and the hook is 8 metersfrom its base. How long is therope? 20 DURING ITS YEARS AS A DOMINION, WHAT WASCANADA'S RELATIONSHIP WITH BRITAIN?A CANADA WAS FULLY INDEPENDENT FROM BRITAIN.B. CANADA GOVERNED ITSELF, BUT BRITAIN CONTROLLEDCANADA'S FOREIGN AFFAIRS. BRITAIN GAVE CONTROL TO FRENCH CANADIANS, NOTBRITISH CANADIANS.D BRITAIN GOVERNED CANADA AND ITS PROVINCESDIRECTLY. Which lengths can be used, directly or indirectly, to calculate the volume of the hexagonal right pyramid? Select three options. XY and ST VU and TW XS and XW TX and WX VU and YZ I need help math plz help me Which climate has subclimates with humid summers as well as subclimates with long, bitterly cold winters? polar tropical rainy temperate marine temperate continental help me with this please. Sometimes a cell is compared to a city. How would the energy needs of a cell be compared to the energy needs of a city? ! Olivia has 5 coupons! She wants a new tablet. The tablet originally cost $800. She has a coupons for 5% off, 10% off, 15% off, 20% off, and 25% off.What is the final price after she applies each coupon? Show work. What is the force needed to accelerate a 10 kg object at 2 m/s?? What did you notice happening with the amino acid molecules in the cell? Why did the Dakota think there should be a war? There are two tall slides at the newly opened theme park, a blue slide and a red slide. The slides have such a height that, if it weren't for friction and air resistance, riders would travel twice as fast at the bottom of the blue slide as they do at the bottom of the red slide. If the red slide is 8m tall, how tall is the blue slide? Why cant a reporter get in trouble for printing a story thats critical of the government? Solve each equation 5x-2=84x-3=2x + 96x+3=2x+8 A group of 80 students was asked to share how they get to school most of the time. The following circle graph represents their answers to the question. How many of the students walk to school most days?0242025 Cules son las necesidades/libertades bsicas de una sociedad justa? What is the answer for 3/4g = -12