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:
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...
-
Miller Corporation has a current ratio of 1.1. Ron has always been told that a corporations current ratio should exceed 2.0. Miller argues that its ratio is low because it has a minimal amount of...
-
Compare Porter's three generic strategies.
-
The discipline of neuroscience makes use of network theory to identify the structures relating to functionality of the brain. Consider the paper by Vrtes et al. [469]. You do not need to study all...
-
The three blood banks in Franklin County are coordinated through a central office that facilitates blood delivery to four hospitals in the region. The cost to ship a standard container of blood from...
-
Plot the following 2-D diagram using MATLAB/OCTAVE command line/m-file Y (3 to 0 and 0 to 3) 2.5 N 1.5 1 0.5- Test image of your student ID> X (0 10 6)
-
Given the electron cloud within the prism with vertices at (2, 2, 4), (2, -2, 4), (-1, 2, 4), (-1, -2, 4), (2, 0, 0), and (-1, 0, 0). a) Sketch the x-y trace, x-z trace, and y-z trace. [3 marks] b)...
-
In 2020, Dr. Chens daughter is 7-year old, and Dr. Chen is planning for his daughters college fund. He expects his daughter to start her college education at the age of 18, which is 11 years from...
-
Please find the price of the following bond: $1,000 face value. 6% semi-annual coupon, 5.5% market rates, and 8 years to maturity.
-
= - An npn differential amplifier with I = 0.2 mA, VCC-VEE-1.5 V, and Rc-5 k utilizes BJTs with = 100 and VBE = 0.7 V at ic = 1 mA. If vg2 = 0, find VE, Ve1, and VC2 obtained with v = +0.5 V, and...
-
Objectives of International Working Capital Management..
-
(a) Find the magnitude of the gravitational force (in N) between a planet with mass 9.00 x 1024 kg and its moon, with mass 2.75 x 1022 kg, if the average distance between their centers is 2.90 x 108...
-
The charter of Spiggott Ltd. specified a maximum of 25,000 common shares. At the current date, 5,000 shares remain unissued, and 2,000 of the issued shares have been reacquired and are still held by...
-
Why is it necessary to study the diffusion of molecules in biological systems?
-
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...
-
A second-order dynamic system is modeled as \[9 \ddot{x}+6 \dot{x}+\frac{10}{9} x=14 \delta(t), \quad x(0)=0, \quad \dot{x}(0)=-\frac{1}{4}\] a. Find the response \(x(t)\) in closed form. b. Plot the...
-
Consider a first-order system with time constant \(\tau\) and zero initial condition. Find the system's unit-step response for \(\tau=\frac{1}{3}\) and \(\frac{2}{3}\), plot the two curves versus \(0...
-
a. Identify the damping type and find the free response. b. Plot the free response by using the initial command. \(\ddot{x}+3 \dot{x}+4 x=0, \quad x(0)=\frac{2}{5}, \quad \dot{x}(0)=0\)
Study smarter with the SolutionInn App