Write a program, stored in a file named highest scoring words.py, that performs the following task....
Fantastic news! We've Found the answer you've been seeking!
Question:
![Write a program, stored in a file named highest scoring words.py, that performs the following task. Prompts](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/08/64d4d96a4a34d_1691670888673.jpg)
![The highest scoring word is abator $ python3 highest scoring_words.py Enter between 3 and 10 lowercase](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/08/64d4d6a2a8625_1691670178251.jpg)
Transcribed Image Text:
Write a program, stored in a file named highest scoring words.py, that performs the following task. • Prompts the user to input between 3 and 10 lowercase letters (with possibly whitespace inserted any- where); if the input contains too few or too many lowercase letters or any character which is neither a lowercase letter nor whitespace, then the program outputs an error message and exits. Finds in the file dictionary.txt, assumed to be stored in the working directory, the words built from the letters input by the user (with the exclusion of any other character) with highest score, if any; the score of a word is defined as the sum of the values of the letters that make up that word, the value of each letter being defined as follows: a g m 2 b 5 С 5h 5 i 5 n 2 0 s 1 t 2 y 5 z 7 f6 4 d 4 e 1 1 j 7 k 6 3p 5 q 7 3 r 2 11 4 V 6 W 6 X 7 Outputs a specific message if there is no such word; otherwise, outputs the highest score and all words with that score, one word per line, with a different introductory message depending on whether there is a unique such word (in which case the introductory message is on the same line as the word) or at least two such words (in which case the introductory message is on a line of its own and all words are preceded with 4 spaces). Here is a possible interaction. $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: abc2ef Incorrect input, giving up... $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: ab Incorrect input, giving up... $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: abcdefghijk Incorrect input, giving up... $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: zz zz zz No word is built from some of those letters. $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: a a a The highest score is 2. The highest scoring word is a $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: a e 1 ou The highest score is 8. The highest scoring words are, in alphabetical order: 10u oui $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: pragroa The highest score is 24. The highest scoring word is program $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: a b e or at The highest score is 16. The highest scoring word is abator $ python3 highest scoring_words.py Enter between 3 and 10 lowercase letters: r a mm oxy The highest score is 17. The highest scoring words are, in alphabetical order: mayor moray moxa oryx $ python3 highest scoring_words.py Enter between 3 and 10 lowercase letters: eaeo rtsmn The highest score is 17. The highest scoring words are, in alphabetical order: matrons. transom 5 Write a program, stored in a file named highest scoring words.py, that performs the following task. • Prompts the user to input between 3 and 10 lowercase letters (with possibly whitespace inserted any- where); if the input contains too few or too many lowercase letters or any character which is neither a lowercase letter nor whitespace, then the program outputs an error message and exits. Finds in the file dictionary.txt, assumed to be stored in the working directory, the words built from the letters input by the user (with the exclusion of any other character) with highest score, if any; the score of a word is defined as the sum of the values of the letters that make up that word, the value of each letter being defined as follows: a g m 2 b 5 С 5h 5 i 5 n 2 0 s 1 t 2 y 5 z 7 f6 4 d 4 e 1 1 j 7 k 6 3p 5 q 7 3 r 2 11 4 V 6 W 6 X 7 Outputs a specific message if there is no such word; otherwise, outputs the highest score and all words with that score, one word per line, with a different introductory message depending on whether there is a unique such word (in which case the introductory message is on the same line as the word) or at least two such words (in which case the introductory message is on a line of its own and all words are preceded with 4 spaces). Here is a possible interaction. $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: abc2ef Incorrect input, giving up... $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: ab Incorrect input, giving up... $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: abcdefghijk Incorrect input, giving up... $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: zz zz zz No word is built from some of those letters. $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: a a a The highest score is 2. The highest scoring word is a $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: a e 1 ou The highest score is 8. The highest scoring words are, in alphabetical order: 10u oui $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: pragroa The highest score is 24. The highest scoring word is program $ python3 highest scoring words.py Enter between 3 and 10 lowercase letters: a b e or at The highest score is 16. The highest scoring word is abator $ python3 highest scoring_words.py Enter between 3 and 10 lowercase letters: r a mm oxy The highest score is 17. The highest scoring words are, in alphabetical order: mayor moray moxa oryx $ python3 highest scoring_words.py Enter between 3 and 10 lowercase letters: eaeo rtsmn The highest score is 17. The highest scoring words are, in alphabetical order: matrons. transom 5
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
The local supermarket buys lettuce each day to ensure really fresh produce. Each morning, any lettuce that is left from the previous day is sold to a dealer that resells it to farmers who use it to...
-
Construct the current assets section of the balance sheet shown here from the following data: Yearly Credit Sales b. Inventory Turnover c. Current Liabilities d. Current Ratio e. c. Quick Ratio...
-
What functions are there in the mazeAsn4 module: print_maze(maze) Description: This function displays the maze. The accessible cells are labelled G i.e. green, the blocked cells are labelled R i.e....
-
The following recreation demand function is for a beach: x = 4 (p/500) + q. The visitation amount is represented by x (times), the travel cost is represented by p (yen), and the water quality is...
-
Advance Leasing calculates the monthly payments on its three-year leases on the basis of recovering the capital cost of the leased equipment and earning a 13.5% compounded monthly rate of return on...
-
List the types of organizations that The Joint Commission accredits.
-
Airport delays. An article in a midwestern newspaper about flight delays at major airports said: According to a Gannett News Service study of U.S. airlines performance during the past five months,...
-
The income statement of Health 24 City Club for the month ending August 31 shows Membership Dues Revenues of $25,000; Salaries Expense of $9,300; Repairs and Maintenance Expense of $2,400; and Net...
-
What is implied volatility? How do you use this concept to invest in call. Be specific
-
The received signal in a digital base band system is either +A or -A, equally likely, for T-second contiguous intervals. However, the timing is off at the receiver so that the integration starts...
-
Suppose a simple random sample of size n=1000 is obtained from a population whose size is N=2,000,000 and whose population proportion with a specified characteristic is p=0.79. Complete parts(a)...
-
Briefly explain the difference between a k-factor model and the capital asset pricing model
-
Refer to the cost data, Picture below. Take off the square feet of wall forms and cubic yards of ready mix concrete for the walls of the elevator pit. Determine the total material and labor cost for...
-
possible Submit quiz A researcher studies water clarity at the same location in a lake on the same dates during the course of a year and repeats the measurements on the same dates 5 years later. The...
-
A liquid hydrocarbon mixture was made by adding 295 kg of benzene, 289 kg of toluene and 287 kg of p-xylene. Assume there is no change of volume upon mixing, i.e., Vmix=0 , in order to determine: 1....
-
b) Maseru Development Bank has R850 million credit with Matsieng Hydroelectric Power, with a maturity of eighteen months. The expected loss for Maseru Development Bank is R22 million, and the...
-
24. Why does it make sense to define materiality from the user's perspective? 25. What similarities are there between materiality and disclosure? 26. Discuss how the concept of conservatism may be...
-
According to a New York Times columnist, The estate tax affects a surprisingly small number of people. In 2003, . . . just 1.25 percent of all deaths resulted in taxable estates, with most of them...
-
In this exercise, you modify the pizza slices program shown in Figure 15-10 in the chapter. If necessary, create a new project named ModifyThis10 Project and save it in the Cpp8\Chap15 folder. Enter...
-
Using the switch statement, write the C++ code that corresponds to the partial flowchart shown in Figure 6-36. Use a char variable named code and a double variable named rate.
-
Rewrite the code from Pencil and Paper Exercises 1 and 2 so that the getProduct function receives two integers, a double number, and the address of a double variable from the calling statement. The...
-
EXCEL CASE The City of Loveland previously adopted GASB Statement 34. Now city officials are attempting to determine reported values for major infrastructure assets that it had obtained prior to the...
-
COMMUNICATION CASE 1 Read the following articles and any other papers that are available on setting governmental accounting standards: 25 Years of State and Local Governmental Financial ReportingAn...
-
ANALYSIS CASE 2 Go to Web site www.portlandonline.com/omf/index.cfm?c=43896 and find the 2006 comprehensive annual financial report for the City of Portland, Oregon. One of the most important changes...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App