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
alexdok [17]
3 years ago
9

A common use-case for dictionaries is to store word counts. Let's modify our program below to store the count for each unique wo

rd. Let's name the dictionary word_counts. This means you need to initialize the count value to 1 for a particular word if you see it for the first time (i.e., it's not already in word_counts) and update the count (by adding 1 to it) if the word is already present in word_counts.
# Code here

# open the file
f = open("words.txt")
# read the text and store in variable
text = ________
# initialize a dictionary
word_counts = ________
# populate the dictionary with words and their associated counts in the text
# for each word in the text (split by spaces)
# if we haven't seen it
# initialize it in the dictionary to a value of 1
# otherwise
# update the count by 1

# print out the word counts
Computers and Technology
1 answer:
baherus [9]3 years ago
8 0

Answer:

word_count={}

for i in text.split:

        if i in word_count:

                word_count[i]+=1

         else:

                 word_count[i]=1

print word_count

You might be interested in
Windows _____ is a system notification utility and gives quick access to settings for items like screen brightness and network c
jasenka [17]

Answer:

Windows notification and action settings

Explanation:

Notification and action settings is a system settings as well as a notification utility that enables quick or easy access to settings for a number of items or features.

The items include network, tablet mode, mobile hotpot, night light, brightness, Bluetooth, airplane mode, all settings, VPN, focus assist, location, project and connect. It is important to note that all the listed items can be found in the notification and action settings of a windows 10 computer.

4 0
3 years ago
Which of the following is not considered a system component that can be found inside a computer? A-CPU B-RAM C-PCIe graphics ada
Julli [10]

The answer is C) PCIe graphics adapter, because it is not required for the computer to work.

8 0
3 years ago
What are some ways you can use the Effect Options dialog box to customize animations in a presentation? Check all
aliina [53]
The first and the 3 ones
4 0
2 years ago
Read 2 more answers
Which of the following is an anxiety disorder
Tju [1.3M]

Answer:Conversion disorder

Explanation:Its a mental condition that affects the nervous system.

3 0
2 years ago
Read 2 more answers
You are a very small company that sells healthcare insurance plans. You estimate that the breach of your customer database will
lozanna [386]

Answer:

C. Accept the risk

Explanation:

The first option is close but might not be suitable for a small company considering it's cost.

The second option which is to spend fifty thousand dollars per year on a data loss prevention solution is projected to cost you more than the risk.

The third option isn't specific and lacks a course of action.

6 0
3 years ago
Other questions:
  • Buildings must be wired to comply with the latest National Electrical Code to ensure that, with adequate maintenance, the instal
    11·1 answer
  • What is the differnces between dark and middle ages of computer?​
    9·1 answer
  • A(n) ________ is a variable that receives an argument that is passed into a function. global argument scope parameter
    15·1 answer
  • Eniac was the first desktop computer. t/f
    5·1 answer
  • Hello my friends i am trying to reboot my i phone 4 but i could not i tried many ways can u help me
    14·1 answer
  • Please write a code for below:
    9·1 answer
  • John’s grandparents make wine for special occasions. They add a pinch of yeast to crushed grapes. Over time, this action release
    15·2 answers
  • Xavier buys a new laptop for $540. He makes a down payment $75 and pays the rest in 6 equal monthly payments, p. What equation r
    7·1 answer
  • What Is the device used to produce hard copies from personal computer ​
    5·2 answers
  • Is e commerce a challenge or opportunity to the freight forwarder
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!