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
Generally, what is the term for storage locations in a processor?
oksano4ka [1.4K]

Answer: Registers

Explanation:

Registers are small storage locations identified by different types of registers. The function of the register is to provide data for immediate processing to the CPU. These registers hold data temporarily and provide easy access of data to the processor.

6 0
3 years ago
Not everything is a success all of the time! So do you know which version of Windows was the least popular?
mario62 [17]

Answer:

windows xp

Explanation:

I think because it is not fast and don't play the games and programs which have higher requirements

7 0
3 years ago
Selena needs to insert a comment in a webpage's code to ensure that other web team members who work with the page code understan
ANTONII [103]

Answer:

<!-- Modified by selena ramirez - for html compliance -->

Explanation:

In HTML, <!-- .. --> tag is used to insert comments in the webpage code.

Comments written inside the tag is visible only on the code, and is not displayed in the browsers when the page is requested by the client computer.

<em>Comment tag</em> is useful when there is a lot of code and multiple developers are dealing with the same code.

Comments help developers understand what changed is made and why.

5 0
3 years ago
I need help with this work
lisabon 2012 [21]

Answer:

B. Balanced depending and the type of questions

5 0
3 years ago
What contains the computer's "brain," the central processing unit (CPU).
vodomira [7]

The computer brain is a microprocessor called the central processing unit (CPU). The CPU is a chip containing millions of tiny transistors.

6 0
3 years ago
Other questions:
  • Which protocol would you utilize to upload files to a web server?
    14·1 answer
  • What changes do you need to a algorithm to compare 100 numberst
    7·1 answer
  • Asking yourself questions can help you think of what to _____, in order to get answers.
    8·1 answer
  • Which of the following is a basic principle of improvement?
    13·1 answer
  • Using ________ data mining, the user usually begins by telling the data mining software to look and test for specific patterns a
    15·1 answer
  • Is it true or false and incomplete doing can be saved in Paint​
    15·1 answer
  • I need the answer ASAP. I’ll mark brainliest if right
    5·1 answer
  • Type the correct answer in each box. Spell all words correctly.
    12·1 answer
  • To embed a Flash file, you must specify a location for the embedded video clip with the ____ parameter and a size for the clip u
    8·1 answer
  • to see additional functions available in an open desktop, document or website what action should the user perform?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!