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
In general, WAN-specific standards identify specific security requirements for WAN devices. For example, the ___________________
allsm [11]

Answer:

WAN router security standard, Web services standard

Explanation:

Complete statement with blanks filled:

In general, WAN-specific standards identify specific security requirements for WAN devices. For example, the WAN router security standard explains the family of controls needed to secure the connection from the internal network to the WAN router, whereas the Web services standard identifies which controls are vital for use of Web services provided by suppliers and external partnerships.

7 0
2 years ago
What is active server page ?or why is it important?
Thepotemich [5.8K]
For Example,
If You Were Hosting Ark Survival And Suddenly The Server Was Off Then The Players Goes Off.The Server Is How We Connect To The Platform In Order To Do The Action Intended.
5 0
3 years ago
Which of the following statements most accurately describes the strength of different types of accreditation?
tia_tia [17]

Answer:

C I believe but I'm not a hundred percent sure

8 0
2 years ago
In python:
Misha Larkins [42]

Answer:

Following are the code to this question:

list_val = input()#defining a integer variable for input value

test_grades = list(map(int, list_val.split()))#defining test_grades as a list

sum_extra = -999 #defining sum_extra that holds negative integer value

sum_extra = 0#defining sum_extra that holds value

for y in range(len(test_grades)):#defining a for loop to check range of list  

   if(test_grades[y] > 100):# defining if block that check list value is greater then 100

       sum_extra = sum_extra + (test_grades[y] - 100)#use sum_extra variable to hold extra value and add this value

print('Sum extra:', sum_extra)#print value

Output:

101 83 107 90

Sum extra: 8

Explanation:

In the above code a, "list_val" variable is declared, that uses an input method to input the values and declared a "test_grades" variable that uses a list method to add all values in the list.

In the next step, the "sum_extra" variable is declared, which holds some values and defines a for loop to check the range of the "test_grades", and define a if block, that checks list value is greater than 100. If the condition is true, it will remove the extra value, and add it into the sum_extera variable and add its value, and at the last use, print variable to print its value.

6 0
3 years ago
2. A host computer with an IP address of 172.16.29.155 using a subnet mask of 255.255.255.0 and a gateway of 172.16.29.1 pings a
ASHA 777 [7]

Answer:

From the host IP address and subnet mask, you can tell that both computers are on the same network. Host 172.16.29.155 will need to send an ARP request broadcast for 172.16.29.83 to get the MAC address and update its ARP table if the host 172.16.29.83 has not already done so.

Explanation:

<h2>ADDRESS RESOLUTION PROTOCOL (ARP)</h2>

Address Resolution Protocol (ARP) is a procedure for mapping a logical address known as the IP address to a physical address known as MAC (Media Access Control) address in a local area network. The job of the ARP is essentially to translate 32-bit addresses to 48-bit addresses and vice-versa when using IP Version 4 (IPv4) to communicate on the network.

Most of the computer programs/applications use logical address (IP address) to send/receive messages, however, the actual communication happens over the physical address (MAC address) this happens in the layer 2 of the OSI model. An ARP request is a broadcast, and an ARP response is a Unicast.

Scenarios when ARP is used:

Scenario-1: The sender is a host and wants to send a packet to another host on the same network.

·        Use ARP to find another host’s physical address

Scenario -2: The sender is a host and wants to send a packet to another host on another network.

·        Sender looks at its routing table.

·        Find the IP address of the next-hop (router) for this destination.

·        Use ARP to find the router’s physical address

Scenario -3: the sender is a router and received a datagram destined for a host on another network.

·        Router checks its routing table.

·        Find the IP address of the next router.

·        Use ARP to find the next router’s physical address.

Scenario -4: The sender is a router that has received a datagram destined for a host in the same network.

·        Use ARP to find this host’s physical address.

The situation in the question above falls under scenario-1. From the host IP address and subnet mask, you can tell that both computers are on the same network. Host 172.16.29.155 will need to send an ARP request broadcast for 172.16.29.83 so to get the MAC address and update its ARP table if the host 172.16.29.83 has not already done so.

7 0
3 years ago
Other questions:
  • What is a negative impact of digital communication
    6·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    5·1 answer
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • The blank contains the computer's brain the central processing unit CPU
    8·1 answer
  • What is the iterative procedure of recursive and nonrecursive?
    10·1 answer
  • In the last two decades, how have cameras evolved?
    12·2 answers
  • Calcula l'energia (Kwh) consumida per una màquina de 30 CV que funciona durant 2 hores.
    12·1 answer
  • Luis saves an attachment that he received from Kevin. Where will the attachment save by default?
    5·1 answer
  • 4. Contoso, Ltd. has a vigorous Office 365 and Azure cloud-service presence.
    8·1 answer
  • an existing technology that would allow users to transfer images from the camera to the computer without connecting them
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!