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
Now tell me how be rich like Bill Gates
Lunna [17]
Get a good education and a good job and stay focused in life
5 0
3 years ago
which tag does not display the text in the browser window and makes the sources code mode readable ?​
maxonik [38]

Answer:

HTML comments are not displayed in the browser, but they can help document ... You can add comments to your HTML source by using the following syntax: <! ... you can comment out HTML lines of code, one at a time, to search for errors: ... Use the HTML comment tag to make a comment out of the "This is a comment" text.

Explanation:

Gimme brainliest right now.

3 0
3 years ago
Which best compares portrait and landscape orientations?
julsineya [31]
#2: Portrait taller than wide & landscape wider than tall
8 0
3 years ago
Short notes on primary key​
Thepotemich [5.8K]

Answer:

A primary key is a special relational database table column (or combination of columns) designated to uniquely identify each table record. A primary key is used as a unique identifier to quickly parse data within the table. A table cannot have more than one primary key.

Primary Key.

Candidate Key.

Alternate Key.

Super Key.

Composite Key.

Foreign Key.

Unique Key.

In the relational model of databases, a primary key is a specific choice of a minimal set of attributes that uniquely specify a tuple in a relation. Informally, a primary key is "which attributes identify a record," and in simple cases constitute a single attribute: a unique ID.

Explanation:

5 0
2 years ago
Access time is:________.
worty [1.4K]

Answer:

B) the time it takes for the required sector to position itself under the read/write head.

Explanation:

In Computer science, Access time is the time it takes for the required sector to position itself under the read/write head. It is usually measured in milliseconds.

It is the speed of the storage device.

5 0
3 years ago
Other questions:
  • In Java Write a program that prompts the user for a name (any String value would work for testing), and print a hello message to
    15·1 answer
  • Develop a Matlab program that allows you to plot the entropy of a source with variable output probabilities. We wish to observe
    8·1 answer
  • List the names of 3 computer scientists
    6·2 answers
  • A mobile device user has tried to install a new app numerous times without success. She hasclosed all unused apps, disabled live
    12·1 answer
  • What does FLUX do when soldering an electrical joint?
    13·2 answers
  • A form letter can be customized by using different fields in a __________.
    15·2 answers
  • Siapa mahapatih brainly.com atau yg disebut Brainly Amerika Serikat ?​
    5·1 answer
  • Full meaning of CASE in system analysis
    11·2 answers
  • A group of two or more computer systems linked together via communication devices is called:.
    10·1 answer
  • Explain why regular system cleanup is vital to ensuring the operating system runs efficiently. ?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!