Write a Python program to do the following: 2. 1. Ask the user to enter several...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python program to do the following: 2. 1. Ask the user to enter several sentences, one at a time (in a loop). To end the sentence entry, the user enters a blank (empty) sentence. Each sentence should be put in a list (SentenceList). Extract each word from each sentence and put it in a new list (WordList). This will require a loop to go through each sentence in the SentenceList. It is up to you how you want to get the words from each sentence. 3. After you get the list of all the words (WordList), calculate the number of times each word appears in the WordList. In order to do this, process the data (using a loop) to use a dictionary (WordDictionary) with the word as the key, and the count as the value. The words are not case sensitive. For example, "House" and "house" are the same words. Assume that the only punctuation used is a period. You must be able to remove the period while processing. In other words, "last" and "last." are the same since you need to remove the period. 4. Display the dictionary (Word Dictionary). When displaying the results, iterate through the dictionary so you can control the way the information is displayed. DO NOT simply print the whole dictionary at once. Example interaction: Program prompts the user for sentences, terminated but a blank/empty sentence: User enters: The house of thunder. User enters: The top of the list. User enters: <blank line> Program displays: the: 3 house: 1 of: 2 thunder: 1 top: 1 list: 1 Very useful hint: This appears as a rather complex program in its entirety. If you try each part separately, you will gain the knowledge needed to build the full solution successfully. Submit the .py file, with header comments and any other comments you feel are necessary, to the folder for this assignment. Write a Python program to do the following: 2. 1. Ask the user to enter several sentences, one at a time (in a loop). To end the sentence entry, the user enters a blank (empty) sentence. Each sentence should be put in a list (SentenceList). Extract each word from each sentence and put it in a new list (WordList). This will require a loop to go through each sentence in the SentenceList. It is up to you how you want to get the words from each sentence. 3. After you get the list of all the words (WordList), calculate the number of times each word appears in the WordList. In order to do this, process the data (using a loop) to use a dictionary (WordDictionary) with the word as the key, and the count as the value. The words are not case sensitive. For example, "House" and "house" are the same words. Assume that the only punctuation used is a period. You must be able to remove the period while processing. In other words, "last" and "last." are the same since you need to remove the period. 4. Display the dictionary (Word Dictionary). When displaying the results, iterate through the dictionary so you can control the way the information is displayed. DO NOT simply print the whole dictionary at once. Example interaction: Program prompts the user for sentences, terminated but a blank/empty sentence: User enters: The house of thunder. User enters: The top of the list. User enters: <blank line> Program displays: the: 3 house: 1 of: 2 thunder: 1 top: 1 list: 1 Very useful hint: This appears as a rather complex program in its entirety. If you try each part separately, you will gain the knowledge needed to build the full solution successfully. Submit the .py file, with header comments and any other comments you feel are necessary, to the folder for this assignment.
Expert Answer:
Answer rating: 100% (QA)
SentenceList while True sentence inputEnter a sentence or leave it blank to finish strip if not ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
List and describe all the ethical theories. Give an example (for each) of a situation where you think application of the theory would or would not be justified. 15 pts What are your takeaways from...
-
The code that you add to the Craps main method needs to do the following steps in the following order (where indicated by the comments in the code itself): 1. Declare an integer array named counts...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Explain why it has been suggested that the new rules in IFRS 16 could bring the biggest shake-up to retailers financial statements for decades.
-
A rectangle measuring 30.0 cm by 40.0 cm is located inside a region of a spatially uniform magnetic field of 1.25 T, with the field perpendicular to the plane of the coil (Fig. 29.29). The coil is...
-
The ages of 44 volunteers at a food pantry are as follows. a) Construct a frequency distribution with a first class of 4247. b) Construct a histogram. c) Construct a frequency polygon. In Exercise,...
-
Calculate the range for each of the following sets of data: a. \(4,6,9\) b. \(14,17,11,19,12\) c. \(25,22,27,30,21,26,29\) d. \(10,8,4,16,9,7,9,13,6,11\) e. \(73,66,91,84,69,87,62,79,82,90\) f....
-
For fiscal year 2011, Starbucks Corporation (SBUX) had total revenues of $11.70 billion, net income of $1.25 billion, total assets of $7.36 billion, and total shareholders equity of $4.38 billion. a....
-
American Food Services, Incorporated leased a packaging machine from Barton and Barton Corporation. Barton and Barton completed construction of the machine on January 1, 2024. The lease agreement for...
-
An infinite cylinder of radius R carries a uniform surface charge density o. We propose to set it spinning about its axis, at a final angular velocity ws. How much work will this take, per unit...
-
The 3-in.-diameter rod carries a bending moment of 2210 lb-ft and the torque T. Determine the largest T that can be applied if the working stresses are Ow= 18 ksi and Tw = 14 ksi.
-
On January 1, 2020, Sage Company issued 10-year, $1,810,000 face value, 6% bonds, at par. Each $1,000 bond is convertible into 15 shares of Sage common stock. Sage's net income in 2020 was $403,200,...
-
Find the value of y if AC-3y+5, CB=4y-1, AB=9y-12, and point C lies between A and B.
-
Luthan Company uses a plantwide predetermined overhead rate of $ 2 2 . 2 0 per direct labor - hour. This predetermined rate was based on a cost formula that estimated $ 2 6 6 , 4 0 0 of total...
-
Determine the vertex of the parabola representing the function f(x)=-2x^(2)+12x-22 using two symmetric points. Find the x-values of the two symmetric points by setting f(x)=-22.
-
Warnerwoods Company uses a perpetual inventory system. It entered into the following purchases and sales transactions for March. Date Activities Units Acquired at Cost Units Sold at Retail March 1...
-
An entity name Ventures Inc. started a trading business on 1 December 2020 with L$200,000 and deposited the money into a bank. Other transactions for the month of December 2020 were: Date 2/12/2020...
-
Clark, PA, has been engaged to perform the audit of Kent Ltd.s financial statements for the current year. Clark is about to commence auditing Kents employee pension expense. Her preliminary enquiries...
-
Harold Conners (Social Security number 785-23-9873) lives at 13234 DeMilo Drive, Houston, TX 77052, and is self-employed for 2012. He estimates his required annual estimated tax payment for 2012 to...
-
On September 14, 2012, Jay purchased a passenger automobile that is used 75 percent in his accounting business. The automobile has a basis for depreciation purposes of $35,000, and Jay uses the...
-
Professor Patricia (Patty) Pate is retired from the PalmSprings Culinary Arts Academy (PSCAA). She is a single taxpayer and is 68 years old. Patty lives at 98 Colander Street, Henderson, NV 89052....
-
For the finite square well potential, prove the formula for the transmission coefficient (7.83), calculate \(R\), and prove that \(|R|^{2}+T=1\). Equation 7.83:- T = |S|2 K3 = 42 2(+)2 cos KL + (2 +...
-
The data in Table 1 represent the first exam score of 10 students enrolled in Introductory Statistics. Treat the 10 students as a population. (a) Compute the population mean. (b) Find a simple random...
-
Consider an asymmetric potential barrier, with Calculate the tunneling probability \(T\) for energy \(U_{1} U_{0}\). 0, x < 0 U(x) = U> U, 0 < x 0, x > L. (7.96)
Study smarter with the SolutionInn App