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
Vinil7 [7]
3 years ago
10

Write a program that reads a book (a file in text format), breaks each line into words, strips whitespace and punctuation from t

he words, and converts them to lowercase. Count the total number of the words, the number of times each word is used, and print out the top 10 most frequently used words.

Computers and Technology
1 answer:
diamong [38]3 years ago
4 0

Answer:

Following are the code to this question:

file= open('book.txt') #open file

li= {} #define an empty list

for lines in file: # use for loop Split file data into words

   d= lines.lower().strip(' !?').split() #define variable d that Add it to map

   for val in d: #define loop to store data  

       if val not in li: #check value is not in list

           li[val] = 0 #define list and assign value in 0

       li[val] = li[val] + 1 #Sort the book data and add its value  

m = sorted(li.items(),key = lambda x : -x[1]) #sorted value into the m variable  

print(m[:10]) #print value

Output:

please find the attachment.

Explanation:

In the given python code first, we open the file "book.txt", in next line, an empty list is defined, that uses the for loop which can be described as follows:

  • In the for loop is used, that reads the file data, and defines a variable "d", that stores the values into the map.
  • In the next line another loop is used, that check file values, if values are the same type so, it adds values and writes it.  
  • In the last line, m variable is used, that sorts the values and use the slicing to print its value.

You might be interested in
The key invention that enabled computers to go into every home and office is
Scrat [10]
<span><span />The Microprocessor is the key invention that enabled computers to go into every home and office. Microprocessor is a computer processor that enables the computer to run. It is also called as central processing unit. It is also a multipurpose and programmable device that accepts inputted data and process the data to provide an output. Microprocessor started from 8-bit design to 16bit, 32 bit, 64 bit and now it is produce a multi core design in the market. Faster and stronger design that can run heavier applications.</span>



8 0
3 years ago
HELP ME PLEASE !!!!!!!!!!
Snezhnost [94]

Answer:

the last one

Explanation:

8 0
3 years ago
A technician wants to update the organization's disaster recovery plans. Which of the following will allow network devices to be
Illusion [34]

Answer:B) Archives/backups

Explanation: Archive is the group of records of data that are saved for the future use.These are the historic data that is not currently used in the actual location .

Backup is the the the copy of the group of data that is not in the original form to be used in future. Thus the correct option is option(B).

Updating of the plans by the technician cannot be done through other given options because they don't hold the historic records of the data for the renewing of the plans.

6 0
3 years ago
By arranging users into security groups, it is possible to set permissions at a group-level, avoiding the unwieldy alternative o
Anni [7]

Answer:

The department by department is arranging users into security groups to set permission at a group-level.

Explanation:

Team by team is just formed group method but the team been set will work on based on the project. Once the project is getting over then the team group assigned permission has to be disabled or deleted.

 

Department by department is just good methods where each department will have a list of users and easy to assign the group.

user-by-user. is just assigning the rights of each individual user. But if the user has multiple departments login it will be good advice.

organization-by-organization. It is just assigning rights to complete users list in the organization.  

6 0
3 years ago
3.1.5 Which network component connects a device to transmission media and allows the device to send and receive messages?
Rom4ik [11]

Answer:

Network Interface Card (NIC)

Explanation:

Also called Ethernet Card, the Network Interface Card (NIC) allows a computer or any device to make wired or wireless connections with other devices in a network. This connection made possible by the NIC allows the device to send and receive messages in the network.

An application of this is seen in Internet of Things(IoT) where devices communicate with one another. This is actually possible because all of the devices one way or the other have a network interface card.

8 0
2 years ago
Other questions:
  • Ryan wants to ensure that all the words in this document are evenly spaced so that they look neat and readable . Which option in
    12·1 answer
  • Can I change my brainly username?
    9·2 answers
  • Climate is considered a(n) _______ limiting factor. (2 points)
    9·1 answer
  • What does the following code output? System.out.println((5+20 + 5)<br> * (10 / 10))
    9·1 answer
  • Write a Python program that translates a binary number of n bits to a decimal number. Your program should first ask the user the
    8·1 answer
  • A standard for compressing music into computer files that can be easily exchanged on the Internet is called a(n) ______. A. musi
    5·1 answer
  • Which key should you press and hold to select multiple cells?
    8·2 answers
  • Use the_____icon to insert a new record.<br><br> A. *<br> B. X<br> C. =<br> D. &amp;
    11·1 answer
  • A computer consists of both software and hardware. a)Define the term software​
    5·1 answer
  • FILL IN THE BLANK.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!