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
Illusion [34]
2 years ago
10

Write a Python program called wdcount.py which uses a dictionary to count the number of occurrences of each word (ignoring case)

in a pure text file encoding UTF-8. Note that the input text file name is given from the command line. To make it simple, you may assume that the file does not contain any punctuation characters. Your program should print each word along with its number of occurrences in descending order. That is the most frequent word should be printed first.
Computers and Technology
1 answer:
Art [367]2 years ago
5 0

The program is an illustration of loops.

<h3>What are loops?</h3>

Loops are program statements used to perform repetition

<h3>The wordcount.py program</h3>

The program written in Python, where comments are used to explain each line is as follows

# This opens the file in read mode

text = open("myFile.txt", "r")

# This creates an empty dictionary

d = dict()

#This iterates through the text

for line in text:

# This splits the line into words, after removing leading & trailing spaces, and newline characters

words = line.strip().lower().split(" ")

# This iterates through all the words

for word in words:

 # The following if condition counts the occurrence of each word

 if word in d:

  d[word] = d[word] + 1

 else:

  d[word] = 1

#This prints the words and their frequencies, in descending order

for w in sorted(d, key=d.get, reverse=True):

   print(w, d[w])

Read more about loops at:

brainly.com/question/16397886

You might be interested in
What do you think about net neutrality??
Tomtit [17]
I think net neutrality should be kept! Removing net neutrality is unfair for all those who use the Internet! I think life would change is net neutrality did. Certain websites (a lot!) would slow down and cause a lot of people inconvenience, and I bet we'd have to pay more to use some sites!!!

NET NEUTRALITY SHOULD BE PRESERVED!!!!
6 0
3 years ago
Read 2 more answers
Ryan is looking to buy a new HDTV set. He knows from friends that LCD set screens reflect less light than plasma set screens, bu
lbvjy [14]

Answer: Cognitive

Explanation:

 According to the question, the Ryan shows cognitive attitude towards the HDTV. The cognitive component basically refers to the three main components that are:

  • Thoughts
  • Beliefs
  • Attributes

The cognitive component is one of the type of attitude which basically consist of various types of thoughts, knowledge and the beliefs towards the any type of object. It is one of the belief and opinion of the attitude.  

3 0
3 years ago
When a formula contains the address of a cell, it is called a(n)
Shalnov [3]
When a formula contains the address of a cell, it is called a c<span>ell reference.

hope this helps!</span>
8 0
3 years ago
Let’s say you attach four images to accompany an important tweet that you’ve composed in the Hootsuite Compose Box. On Twitter,
Damm [24]
I doub between:

<span>  C)  A series of 4 full size, but individual tweets (with the tweet copy appearing above the first image of the series)  D)  A collage format, with full size images</span>

6 0
3 years ago
In most operating systems what is running application called?
Likurg_2 [28]

Answer:

I believe it is just a task. Since there exists(on windows) the Task Manager application, where you can stop any running <em>task, </em>I think that they are called tasks

Explanation:

5 0
3 years ago
Other questions:
  • what is a massive online storage that allows for access by any Internet connected device running a web browser and is used for l
    7·1 answer
  • An array name and index are separated using ____.
    13·1 answer
  • Mr. Perry has bookmarked a large number of webpages in Chrome while researching class topics. Unfortunately, he's bookmarked so
    13·1 answer
  • Match the job titles to the tasks
    11·2 answers
  • Is anyone really good at immerse 2 learn??
    9·1 answer
  • A 5-stage MIPS pipeline has a register file without forwarding mechanism. How many NOPs (or bubbles) will you need to add to mak
    9·1 answer
  • Fill in the blanks of the SQL Statements: Fund_Id VARCHAR(10) , Donor_id VARCHAR(10) , Count_Of_Receipts INTEGER, Total_Receipts
    15·1 answer
  • Help help help help help!!!
    7·1 answer
  • What are price comparison websites?
    6·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!