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
Svetradugi [14.3K]
3 years ago
5

Write a function wordcount() that takes the name of a text file as input and prints the number of occurrences of every word in t

he file. You function should be case-insensitive so 'Hello' and 'hello' are treated as the same word. You should ignore words of length 2 or less. The results printed will be ordered from the most frequent to the least frequent. Hint: dictionary and list. Test your implementation on file great_expectations.txt
Computers and Technology
1 answer:
artcher [175]3 years ago
4 0

Answer:

Explanation:

The following Python program uses a combination of dictionary, list, regex, and loops to accomplish what was requested. The function takes a file name as input, reads the file, and saves the individual words in a list. Then it loops through the list, adding each word into a dictionary with the number of times it appears. If the word is already in the dictionary it adds 1 to its count value. The program was tested with a file named great_expectations.txt and the output can be seen below.

import re

def wordCount(fileName):

   file = open(fileName, 'r')

   wordList = file.read().lower()

   wordList = re.split('\s', wordList)

   wordDict = {}

   for word in wordList:

       if word in wordDict:

           wordDict[word] = wordDict.get(word) + 1

       else:

           wordDict[word] = 1

   print(wordDict)

wordCount('great_expectations.txt')

You might be interested in
For all those among our fans and SpongeBob fans which is better SpongeBob or amount us
Ivenika [448]

Answer:

!!!!SPONGEBOB!!! XD

Explanation:

5 0
3 years ago
Read 2 more answers
Which model allows you to make subsystems in parallel?
boyakko [2]
The model is Parallel Distributed Processing Model (PDP) wherein m<span>Memory results from weblike connections among interacting processing units operating simultaneously, rather than sequentially ( also known as the connectionist model).</span>
8 0
3 years ago
Jamie Lee is beside herself knowing that the thieves had unauthorized use of her debit/ATM card. What is Jamie's financial respo
Rama09 [41]

Jamie's financial responsibility for the unauthorized use is dependent on how fast she report the theft of her debit/ATM card.

Since Jamie Lee is dealing with an unauthorized use of  her ATM or debit card,  she ought to  act quickly so as  to avoid full liability for unauthorized charges since her card was stolen.

According to Federal laws and bank policies, Under the Federal Electronic Fund Transfer Act, the following  liability applies:

  •  $0 if she  reports the theft of the card immediately before any unauthorized charges are made.
  • She would be charged up  to $50 if she  notifies  the bank within two business days after she  realized the theft.
  • She would be charged up to $500 if she fails to notify the bank within two business days after the theft  but does notify the bank within 60 days after her  bank statement is mailed to her with a list of  the unauthorized withdrawals.
  • She wold be charged unlimited charges if she  fails to notify the bank within 60 days after her bank statement is mailed to her listing the unauthorized withdrawals.

From the polices applicable, It is necessary that Jamie Lees  notifies the bank or card issuer of the theft as soon as possible so as not to incur much financial responsibilites for the unauthorised use.

Read on to learn about  unauthorized use debit/ATM card: brainly.com/question/21485510

8 0
2 years ago
Select the correct answer.
juin [17]

Answer:

A. <Title> tag

Explanation:

Required

Tag that can be written in the <head> element

Of the given options, <title> is correct.

This is so because, it is compulsory to have the <title> tag and the only location where it can be placed is inside the <head> tag.

Its function is to display the title of a page

e.g.

<em><title> This is my first page </title></em>

4 0
3 years ago
Why is this happening when I already uploaded files to my drive?
lara31 [8.8K]

Answer:

u have to upload it to your drive first

Explanation:

7 0
2 years ago
Other questions:
  • To execute a prepared SQL statement, you can use the _______ and execute methods of the PDOStatement object to set parameter val
    9·1 answer
  • Which ipv6 prefix will the typical enterprise network receive from the service provider?
    12·1 answer
  • You resurrected an old worksheet. It appears to contain most of the information that you need, but not all of it. Which step sho
    5·1 answer
  • For every $1 of deposits, the banks can increase ________________ by the value of the Money Multiplier.
    15·1 answer
  • ___________________ are aggregated collections of memory and cpu resources that can be shared among groups of virtual machines o
    11·1 answer
  • Which line correctly starts the definition of a class named "team"?
    7·1 answer
  • Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the cou
    8·1 answer
  • A nested folder can best be described as what?
    12·1 answer
  • I am making a project i have to advertise a product i picked a futureistic car
    10·1 answer
  • When heading styles have been applied to a document, the user has the option to navigate through the document using which tab on
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!