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
A network manager prevents users accessing certain websites. She does this by setting up:
Rus_ich [418]

Answer:

A or B

Explanation:

Firewalls and internet filters are the same thing, people nowadays tend to use "internet filters" more, but again they mean the same thing.

7 0
4 years ago
True or False
OverLord2011 [107]

Answer:False

Explanation:

7 0
3 years ago
Shovels and Shingles is a small construction company consisting of 12 computers that have Internet access. The company's biggest
Y_Kistochka [10]

Answer:

The Encryption solution that best prevents a competitor from receiving confidential information is the SSL(secure Socket Layer) Or TLS(Transport Layer Security).

Explanation:

Solution:

From my own perspective the encryption solution that i will use that prevents s a competitor from receiving confidential information and justify the recommendation is the SSL(secure Socket Layer) Or TLS(Transport Layer Security).

This is because in this case we have to share data confidentially (information need to be hidden from Unauthorized  security access. also these provides the Transport Layer security that we needed in above example above.

The purpose of these protocol is to provide server and client authentication, Data confidentiality,and Data integrity (protected from unauthorized change). Application Layer client/server program such as HTTP that uses the service of TCP can encapsulate their data in SSL Packets.

SSL (Secure Socket Layer): is defined as the normal technology for protecting an internet connection secure and defend any sensitive data that is being sent between two systems, and not allowing criminals from reading and changing any information sent, including potential personal details.

TLS (Transport Layer security): It is a procedure that allows  data integrity  and privacy over Internet communications.

3 0
3 years ago
What motivated Barbara MBANEFO to become an engineer?
luda_lava [24]

Answer:

to help her community and give hope to others

Explanation:

8 0
3 years ago
Read 2 more answers
Daisy, an HR executive at Matrix-Solutions, was given the responsibility to conduct induction training for the newly hired emplo
sasho [114]

Answer:

The answer is Presentation Software.

Explanation:

The application that best suits her purpose is a Presentation Software. Such as: powerpoint, google presentations, keynote,  OpenOffice Impress, Media Shout, Harvard Graphics, Adobe Persuasion.

These are excellent tools for Daisy's purpose.

8 0
3 years ago
Other questions:
  • In what year was google launched on the web?
    14·1 answer
  • Read the sentence.
    10·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • Gabe Kelp is a fourteen-year-old goalie for the Soaring Eagles soccer team. He and his teammates are each creating a screen name
    11·1 answer
  • Animation timing is does not affect the
    10·1 answer
  • MAN speeds are faster than WAN speeds because of ________. technological limitations regulatory limitations
    6·1 answer
  • What are two design elements that help MRAP trucks resist mines?
    15·1 answer
  • When using the protection options in Excel 2016, what does the Protect Workbook function do?
    8·2 answers
  • The programming interface for a legacy motor controller accepts commands as binary strings of variable lengths.
    15·1 answer
  • To call the superclass's no-parameter constructor explicitly, use super(); group of answer choices true false
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!