1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
torisob [31]
3 years ago
12

How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. H

ow to format each item of your inverted dictionary as a text string in the output file.
Computers and Technology
1 answer:
Jet001 [13]3 years ago
7 0

Answer:

- To get the items of a dictionary and print them as a string, use the items() method to unpack the keys and values in a for and print or write them into a file.

for key, value in mydict.items():

   print(f"{key}, {value}")

- To convert string from user input into dictionary;

   mystring = input().split(" ")  #assuming the words are separated by a space.

   from word in mystring:

       mydict[word] = mydict.get(word, 0) + 1

This would use the words in the string as the keys of the dictionary and the count of each word as the respective values.

Explanation:

A dictionary is a data structure in python used to store data in key-value pairs. The items are enclosed in curly braces and can be accessed with the key in dot or bracket notation.

You might be interested in
FOR ALL PLATO USERS:
aleksley [76]

You have to ask you teacher to show you which ones you got wrong and the answers to them.

6 0
4 years ago
Read 2 more answers
Find the errors<br><br> Look to the following code and fix the errors
ivanzaharov [21]
Upper case and lower case problem
7 0
3 years ago
How many nibbles are in 18 bytes??
IgorC [24]
36 Nibbles are in 18bytes.
7 0
4 years ago
Module 1 and 2 Coding Guided Notes Fill in your answers to each response as you read through the lesson pages in the coding cour
creativ13 [48]

Answer:

Code; code; program.

Explanation:

1. Instructions for computers to solve a problem is known as code. Computer code is how humans and machines talk to each other. Some examples of programming language used to write a code in instructing a computer for the execution of a task are python, Java, Javascript, ruby, c++, c# etc.

2. Learning to code or write a program allows for a solution to a problem.

4 0
3 years ago
Read 2 more answers
What kind of network connection do you think is used to connect most wireless video game controllers to consoles, and why would
Ostrovityanka [42]

Answer:

I would say Lan

Explanation:

5 0
3 years ago
Other questions:
  • What is a swap file? how does the computer use this file? what information might be found there?
    6·1 answer
  • Write a method named lastFirst that accepts a string as its parameter representing a person's first and last name. The method sh
    13·1 answer
  • Anybody good with Microsoft excel? I need help with this class.
    9·2 answers
  • Which of the following would you not see on a windows 10 start menu?
    6·1 answer
  • A carver begins work on the following block of granite that weighs 2700 g. What is the density of the granite?
    13·1 answer
  • The property that allows a metal to be drawn into wires is called...
    9·1 answer
  • Write a c++ program that generates three random numbers. The first number should be between 0-30, the second number should be be
    7·1 answer
  • Which of the following shows the assignment of a string to a variable? Select 3 options.
    11·2 answers
  • Is it true that if the user log out the computer will turn off automatically​
    9·2 answers
  • failed logins or instances of denial of access to restricted files may be indicators of compromise. suggest where records of suc
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!