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
Does anybody know how to unlock websites from school computer
Grace [21]

Answer:

yes go to settings then apps

Explanation:

that's how I did mines

8 0
2 years ago
One of the newest electronic conveniences is the ________, which can serve as a credit card, a debit card, and even unlock doors
77julia77 [94]
Computer Chips. / SILICON. This is just an educated guess
7 0
3 years ago
Identify the menu under which you'll find the Header and Footer option.
Genrish500 [490]

The answer is B. View.

4 0
3 years ago
What are some commands found in the Sort dialog box? Check all that apply.
Novosadov [1.4K]

Answer:

A. add level

D. Delete level

E. Copy level

F. Move up or down

Explanation:

I just did it on edg. 2020

4 0
3 years ago
Read 2 more answers
public class Parent { private int value = 100; public int getValue() { return value; } } public class Child extends Parent { pri
Shalnov [3]

The answer & explanation for this question is given in the attachment below.

3 0
3 years ago
Other questions:
  • Human systems integration (hsi), a supportability issue that every program should consider, addresses such factors as accessibil
    10·1 answer
  • Why should the data in a reservation system that is constantly being updated be stored on a magnetic disk instead of a CD or DVD
    15·1 answer
  • What kinds of online behaviors could be considered cyberbullying?
    7·2 answers
  • In Word, blue underlining indicates which of these problems?
    12·1 answer
  • Data governance consists of? A. the processes, methods, and techniques to ensure that data is of high quality, reliable, and uni
    11·1 answer
  • The blue bar across the top of the screen informs you of the Screen Title, or what step you are on.
    5·1 answer
  • You are late in the preparation of the computer graphics for your final report and presentation. You run into a friend who is gr
    13·1 answer
  • 50 POINTS! What can be viewed in the Tasks folder? Check all that apply.
    13·2 answers
  • An IT security threat is anything that might cause serious harm to a computer system, including someone stealing a laptop that c
    8·2 answers
  • You must configure a certificate authority on your network to use EFS. True or False?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!