In this assignment, you will write a Python program that asks the user for a list...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In this assignment, you will write a Python program that asks the user for a list of words, and then prints the shortest word, the longest word, and the average length of the words. Here is a sample run of the program (note that user input is in black, and printing from the program is in blue): Python 3.6.5 Shell File Edit Shell Debug Options Window Help Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 b it (AMD64)] on win32 Type "copyright", "credits" or "license ()" for more information. >>> RESTART: U:\cislll\fall18\projects\proj5.py ================ ===== Enter a list of words, separated by spaces: apple carrot pineapple plum watermelon peach Shortest word: plum Longest word: watermelon Average word length: 6.50 >>> X =========== Ln: 10 Col: 4 Also, please note that the list of words entered by the user was typed WITHOUT hitting Enter until after the very last word. The word list was wrapped below to the second line automatically. Requirements Your project file should be named proj5.py. Your program should run the Python shell. If you haven't already, make sure you watch the lectures on Functions, Advanced Functions, Strings, and Strings (Continued), which walk through several examples that are similar to this assignment. Your project must include the following functions: • get_shortest, which takes a list of words as a parameter, and returns the word in the list whose length is the shortest get_longest, which takes a list of words as a parameter, and returns the word in the list whose length is the longest • get_average, which takes a list of words as a parameter, and returns the average length of those words . These functions should be written before the "main code" for the project. I recommend looking at the format of a bigger Python program with functions, like the Hangman program from Lecture 12 and 14. Here are additional tips/requirements for your program: • You may assume that the user will correctly enter a list of words separated by spaces You should round the average word length to two decimal places when printing it (hint: use conversion specifiers) . In this assignment, you will write a Python program that asks the user for a list of words, and then prints the shortest word, the longest word, and the average length of the words. Here is a sample run of the program (note that user input is in black, and printing from the program is in blue): Python 3.6.5 Shell File Edit Shell Debug Options Window Help Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 b it (AMD64)] on win32 Type "copyright", "credits" or "license ()" for more information. >>> RESTART: U:\cislll\fall18\projects\proj5.py ================ ===== Enter a list of words, separated by spaces: apple carrot pineapple plum watermelon peach Shortest word: plum Longest word: watermelon Average word length: 6.50 >>> X =========== Ln: 10 Col: 4 Also, please note that the list of words entered by the user was typed WITHOUT hitting Enter until after the very last word. The word list was wrapped below to the second line automatically. Requirements Your project file should be named proj5.py. Your program should run the Python shell. If you haven't already, make sure you watch the lectures on Functions, Advanced Functions, Strings, and Strings (Continued), which walk through several examples that are similar to this assignment. Your project must include the following functions: • get_shortest, which takes a list of words as a parameter, and returns the word in the list whose length is the shortest get_longest, which takes a list of words as a parameter, and returns the word in the list whose length is the longest • get_average, which takes a list of words as a parameter, and returns the average length of those words . These functions should be written before the "main code" for the project. I recommend looking at the format of a bigger Python program with functions, like the Hangman program from Lecture 12 and 14. Here are additional tips/requirements for your program: • You may assume that the user will correctly enter a list of words separated by spaces You should round the average word length to two decimal places when printing it (hint: use conversion specifiers) .
Expert Answer:
Answer rating: 100% (QA)
listofwords rawinputType in four words separated by a space split Sort the words by the... View the full answer
Related Book For
Data Structures and Algorithms in Python
ISBN: 978-1118290279
1st edition
Authors: Michael T. Goodrich , Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
Keong is considering an investment in Leongs Bar & Grille Corporation. Keong is planning to buy the stock today, hold it for 2 years, and then expects to sell the stock for $30 at the end of 2...
-
Write a small C++ program. Your program should compile correctly and produce the specified output. Please note that the computer program should comply with the commenting and formatting rules as has...
-
Use turtle graphics to create an interactive forest drawing application. Start by creating a module utilities.py which should contain four drawing functions as listed below. draw_triangle(centre_x,...
-
Suppose you own an outdoor recreation company and you want to purchase all-terrain vehicles (ATVs) for your summer business and snowmobiles for your winter business. Your budget for new vehicles this...
-
Let f, g: Z+ R. Prove that f (g) if and only if g 0(f).
-
Use the list below, which shows the 10 U.S. National Parks with the most visitors in 2013. Park........................Location Great Smoky Mountains National ParkNorth Carolina/Tennessee Grand...
-
A snow-cone machine at an icecream shop costs \(\$ 15,000\). The machine is expected to generate profits of \(\$ 2,500\) each year of its 10-year useful life. At the end of the 10 years, the machine...
-
Given the following network for a stock repurchase project with outside consulting resource demands, construct a modified Gantt AOA chart with resources and a resource load diagram. Suggest how to...
-
I am having trouble instaling Oracle database 11g express edition and SQL developer to my computer, validate your installation, and write a short 3- to 4-page paper with screenshots of your download....
-
It is proposed to air-cool the cylinders of a combustion chamber by joining an aluminum casing with annular fins (k = 240 W/m K) to the cylinder wall (k = 50 W/m K). The air is at 320K and the...
-
Question 13 (3 points) The Friendly Sausafe Factoryy (FSF) can produce hot dogs at a rate of 3,100 per day. FSF supplies hot dogs to local restaurants at a steady rate of 370 per day. The cost to...
-
write the code for Wordcount.java to display the output for Average rating and the number of user who rated the movie, the u.data set The following file is from Movielens dataset which shows user...
-
Give an example of a failing internal control and the corrective action.
-
discuss in details the impact of teleworking on organizational commitment and employee work-life balance?
-
Steve is planning for his retirement. He is currently 37 and plans to retire in 26 years, at age 63. He expects then to live an additional 34 years, until age 97. He expects inflation to average 5%...
-
If you buy a 3 year 4% Certificate of Deposit (CD) for 25,000, what is the total interest paid on the CD at maturity?
-
class student { String name; int id; wwwww Can you explain that how to get the output step by step? } public class mq2 { public static void main(String args[]) { ArrayList myArray = new ArrayList ();...
-
Modify the CYK algorithm so that it applies to any CFG, not just those in CNF.
-
Write a pseudo-code description of a function that reverses a list of n integers, so that the numbers are listed in the opposite order than they were before, and compare this method to an equivalent...
-
Draw the recursion trace for the computation of power(2,18), using the repeated squaring algorithm, as implemented in Code Fragment 4.12.
-
Write a Python class that extends the Progression class so that each value in the progression is the absolute value of the difference between the previous two values. You should include a constructor...
-
An MMW side looking SAR has the following specifications: radar velocity v = 70 m/s, elevation angle = 35, operating frequency f0 = 94 GHz, and antenna 3 dB beam width 3dB = 65 mrad. (a) Calculate...
-
Consider a synthetic aperture radar. You are given the following Doppler history for a scatterer: {1000 Hz, 0, 1000 HZ}, which corresponds to times {10 ms, 0, 10 ms}. Assume that the observation...
-
A side looking SAR takes on eight positions within an observation interval. In each position, the radar transmits and receives one pulse. Let the distance between any two consecutive antenna...
Study smarter with the SolutionInn App