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
Problem 1. MST - Prim's and Kruskal's algorithms
Juli2301 [7.4K]
Or maybe not Encryption converts the data in a database to a format that is indecipherable to unauthorized users who attempt to bypass the DBMS.

a. True
b. False
7 0
3 years ago
The number of output for a decoder if the input is 4
WINSTONCH [101]
To get the number ot decoder output:

2^n; where n is number of input
2^4
2 × 2 × 2 × 2 = 16 outputs

3 0
3 years ago
A small Ecommerce company houses their servers locally but they have outsourced their IT work to a local technology company rece
shusha [124]
Service Level Agreement?
3 0
3 years ago
When creating and modifying templates, which keys are used to add placeholders?
beks73 [17]

Answer:

On the Slide Master tab, click Insert Placeholder, and then click the type of placeholder that you want to add. Click a location on the slide layout, and then drag to draw the placeholder. You can add as many placeholders as you like. (For Power point) But not sure about a short cut for it. Hope this helps!

3 0
2 years ago
Read 2 more answers
If you want to protect your identity while social networking, then you might use a(n) ____________ for your profile image
notsponge [240]
Won't you use a fake photo for your profile image or not put one on at all! This is a very safe way to keep your identity a secret and that you are very safe while you are online.

Hope this help!!
4 0
3 years ago
Other questions:
  • Go to the Creamy Ice Corporation passage on the next page. Insert the trademark sign after the word “Corporation'' in the first
    9·1 answer
  • Hi <br> What exactly does this project want from me?thanks for riding
    5·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    13·2 answers
  • 1. Think about the various ways in which you have seen hackers portrayed in popular media over the past few years. Are they hero
    11·1 answer
  • A ____ network (or workgroup) consists of multiple windows computers that share information, but no computer on the network serv
    15·1 answer
  • How can you make a circle in JavaScript? Thank you!
    9·1 answer
  • The user enters a URL into a web browser, the web browser sends the information to the DNS server to look up the IP address, the
    12·1 answer
  • Which question about whale sharks is nonscientific?
    11·2 answers
  • Select the correct answer.
    15·2 answers
  • You can use the ____ method to search a string to determine whether it contains a specific sequence of characters.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!