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
Compare the two types of formatting that IDE devices must go through. What is the primary difference between the two?
Andrei [34K]
A quick format<span> changes the file system while the </span>full format<span> also checks the </span>drive for bad sectors.  <span>The scan for bad sectors is the reason why the Full </span>format<span> takes twice as long as the </span>Quick format<span>. If you choose the </span>Quick format<span> option, the </span>format<span> removes address files from the partition, but does not scan the disk for bad sectors.</span>
7 0
3 years ago
Read 2 more answers
Which of the following is not ways to fix software in windows 8
RideAnS [48]
Well, this is pretty tricky so lets define all the purposes of these

Safe mode - troubleshoots windows ; determines HARDWARE malfunctions

Check device manager - Highlights malfunctioning hardware that is connected to the P.C.

Refreshing pc - practically nothing

resetting your pc - removes all programs, files, etc. and starts as a new Windows.

I will have to go with answer C.) Refresh your P.C.
7 0
3 years ago
A(n) __________is an output device that enable a machine operator to view the acc or pre vlaue of an insstruction without the us
antoniya [11.8K]

A <u>LED display</u> is an output device that enable a machine operator to view the acc or pre vlaue of an insstruction without the use of a programming terminal

<h3>What is LED display device?</h3>

LED Display (light-emitting diode display) is a screen display technology that uses a panel of LEDs as the light source. Currently, a large number of electronic devices, both small and large, use LED display as a screen and as an interaction medium between the user and the system.

<h3>Where is LED display used?</h3>

An LED (Light-Emitting Diode) is a small cell or conductor that glows and becomes illuminated when a voltage is applied to it. The phrase 'LED display' is often used broadly to describe screens on a wide range of devices. This includes commercial and consumer technology such as TVs, mobile phones, and PC monitors.

To learn more about LED Display , refer

brainly.com/question/17019750

#SPJ4

8 0
1 year ago
Define the _make method, which takes one iterable argument (and no self argument: the purpose of _make is to make a new object;
Ksenya-84 [330]
This picture will show you the answer and guide the way to victory

7 0
3 years ago
Write a program using integers userNum and x as input, and output userNum divided by x three times.
andrezito [222]

Answer:

# The user is prompted to enter number as dividend

# The received number is assigned to userNum

userNum = int(input("Enter the number you want to divide: "))

# The user is prompted to enter number as divisor

# The divisor is assigned to x

x = int(input("Enter the number of times to divide: "))

# divideNumber function is defined to do the division

def divideNumber(userNum, x):

   # counter is declared to control the loop

   counter = 1

   # the while-loop loop 3 times

   # the division is done 3 times

   while counter <= 3:

       # integer division is done

       # truncating the remainder part

       userNum = userNum // x

       # the result of the division is printed

       print(userNum, end=" ")

       # the counter is incremented

       counter += 1

# the divideNumber function is called

# the received input is passed as parameter

# to the function

divideNumber(userNum, x)

# empty line is printed

print("\n")

Explanation:

The // operator in python works like the / operator in C. The // operator returns only the integer part of division operation. For instance 6 // 4 = 1. The fraction part is discarded.

7 0
3 years ago
Other questions:
  • When a browser makes a request for a static web page, the web server a. finds the HTML for the page and renders it b. renders th
    11·1 answer
  • Which best describes Sayid’s error?
    13·1 answer
  • As a safe driver, you cannot, __________
    13·1 answer
  • How do you reduce computer screen flicker
    11·1 answer
  • In​ 1972, gordon bell formulated​ bell's law, which states​ ________.
    7·1 answer
  • ________ of Willa Catha present an unadorned picture oflife on the prairies of the Midwestern United States during the19th centu
    8·1 answer
  • Which type of cables are used for high-capacity trunk lines that provide main routes for telephone, cable, and internet communic
    15·1 answer
  • Allows a user to control the<br>volume of the computer​
    8·1 answer
  • Which command could you use to change to the /usr directory using a relative pathname?
    8·1 answer
  • Learning Management Systems (LMS) allow students to interact with each other, but NOT their teachers.
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!