Write a program that counts how often each word occurs

Assignment Help Computer Engineering
Reference no: EM132113582

PYTHON programming, please!

Write a program that counts how often each word occurs in the supplied text file mary.txt.

Your program should output one line for each unique word that occurs in the text file in the format word: count, where word is a word from the file and count is the number of times that word occurs.

Be sure to strip punctuation from words or your program will won't produce the correct output.

(Hint : The dictionary data structure should be used for this problem)

mary.txt is the following

Mary had a little lamb, whose fleece was white as snow. And everywhere that Mary went, the lamb was sure to go. It followed her to school one day which was against the rules.

It made the children laugh and play, to see a lamb at school. And so the teacher turned it out, but still it lingered near, And waited patiently about, till Mary did appear. "Why does the lamb love Mary so?" the eager children cry. "Why, Mary loves the lamb, you know." the teacher did reply.

Reference no: EM132113582

Questions Cloud

Find the z-score corresponding to the area : Find the z-score corresponding to the given area. Remember, z is distributed as the standard normal distribution with mean of 0 and standard deviation of 1.
Write a python program that contains a main function : Write a PYTHON program that contains a main function and a custom, void function namedshow_larger that takes two random integers as parameters.
Asks the user for the number of males and number of females : Write a program that asks the user for the number of males and the number of females registered in a class using two separate inputs.
Mean anxiety score in elementary school children : The mean anxiety score in elementary school children is 14.55. A researcher wants to know if children of anxious parents are more anxious than the average child
Write a program that counts how often each word occurs : Write a program that counts how often each word occurs in the supplied text file mary.txt.
What is the probability that the coin you picked is the fair : Given this information, what is the probability that the coin you picked is the fair one?
Write a function to append lines to a file : Write a function to append lines to a file. Do this in a loop that would allow the user to continue adding lines to a file until they enter the letter q.
Write a program to provide information on the height : Write a program to provide information on the height of a ball thrown straight up into the air.
Determine whether the effect of one variable : Suppose you are trying to use linear regression analysis to determine whether the effect of one variable, X1, on another variable, Y, depends upon

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd