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
In regard to segmentation, all of the following are examples of a customer's behavior or relationship with a product EXCEPT: a)
scZoUnD [109]

Answer: demographics

Explanation:

Market segmentation refers to the process of dividing the consumers into sub-groups of consumers which are refered to as the segments based on the characteristics shared.

The examples of a customer's behavior or relationship with a product include user status, usage rate and loyalty status.

It should be noted that some examples of market segmentation are behavioral, demographic, geographic, and psychographic. From the options given, demographics is not an example of a customer's behavior with a product.

7 0
2 years ago
Word Online works exact same as the downloaded Office 2016 version.<br>True<br>False​
melisa1 [442]

Answer:

The Answer is false. They work similarly but quite differently on a lot of offerings from them. Office 365 and office.com are online version, and Office 2016 is a desktop version.

Explanation:

I am not going very deep into this but the facts I am mentioning will clarify your doubts.

Office 2016 offers so many ways to share a file even though we work offline on it We can email the document, share on social media as well as store on One drive. However, Office 365, and especially Word online does not allow any other sharing options than sending an invitation or sharing a link.

For Word Online you will need internet all the time, though you can work from anywhere, and even on any device. Word 2016 does not require internet, but provide a lot of analytics features and even data mining facilities when it is connected to the internet.

Watch out for Word online 2019 version, and office 2019 desktop version. They are awesome and provides AI features, and a lot more than 2016 versions, both desktop and online.

3 0
3 years ago
If you sort a portion of an Excel sheet and you get an error message such as #DIV/0, what is a likely cause of the error message
yulyashka [42]
<span>If you sort a portion of an Excel sheet and you get an error message such as #DIV/0, the cause of the error message is (B) one or more cells containing absolute cell references. The possible reason of this error message includes: (1) e</span><span>ntering division formula that divided by zero (0), (2) and that is being used as a reference.</span>
7 0
3 years ago
Universal Containers has a requirement to integrate Salesforce with an external system to control record access. What option sho
Inessa05 [86]

Answer:

C. Use the SOAP API to maintain the related SObject_share records

8 0
3 years ago
What are the optional parameters when configuring DHCP
stealth61 [152]

Answer:

DHCP is the dynamic host configuration protocol that enable the server for assigning the IP address to the computer. It is basically used to provide automatic IP addresses within the network. It is basically used to configure the default gateway and provide the DNS server data in the device.  

The optional parameter when configuring DHCP are:

  • Sub-net mask
  • Router
  • Domain server
  • Broadcast address
  • Host name
5 0
3 years ago
Other questions:
  • A book of the Law was found in the Temple, which was being repaired, during what year of Josiah's reign.
    15·2 answers
  • A(n _______________ is a pre-written formula that is built into excel
    12·1 answer
  • If anybody knows what does this mean I will answer any questions for you and plz answer this right plz what does that envelope w
    5·2 answers
  • What laptops can you get for 2500$ and should mostly using Microsoft applications.
    14·2 answers
  • Which command can be used to find errors on a hard drive​
    6·1 answer
  • When gathering information about certain occupations, be sure to understand how you are paid. What is the difference between a s
    12·2 answers
  • About how long did it take to photograph Daguerre's photograph of the street?
    7·1 answer
  • On what menu in Microsoft Word can you locate the Macro feature?
    10·1 answer
  • A short-range wireless network is called:
    10·1 answer
  • Write a function solution that given an array a of n integers (between -100 and 100), returns the sign (-1,0,1) of product of al
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!