1. Write a Python program in a file called processStrings.py which, given a number of strings...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write a Python program in a file called processStrings.py which, given a number of strings of digits, uses a main function to test the following functions: (a) processStr which, given a string of digits, computes and prints the sum and the product of the numbers in the string; (b) getHighest which returns the largest digit/number in the string; (c) getHasRepeatDigit which calls and returns the result from the function getHighest if the string has no repeated digits and zero otherwise. Sample input/output: Enter a string of digits to process or 'quit' to stop: 3294751 The sum of the digits in 3294751 is 31 The product of the digits in 3294751 is 7560 The string has no repeated digits. The highest digit in the given string is: 9 Enter a string of digits to process or 'quit' to stop: 454182 The sum of the digits in 454182 is 24 The product of the digits in 454182 is 1280 repeated digits. The string has Enter a string of digits to process or 'quit' to stop: 832015 The sum of the digits in 832015 is 19 The product of the digits in 832015 is 0 The string has no repeated digits. The highest digit in the given string is: 8 Enter a string of digits to process or 'quit' to stop: 22222 The sum of the digits in 22222 is 10 The product of the digits in 22222 is 32 The string has repeated digits. Enter a string of digits to process or 'quit' to stop: quit 1. Write a Python program in a file called processStrings.py which, given a number of strings of digits, uses a main function to test the following functions: (a) processStr which, given a string of digits, computes and prints the sum and the product of the numbers in the string; (b) getHighest which returns the largest digit/number in the string; (c) getHasRepeatDigit which calls and returns the result from the function getHighest if the string has no repeated digits and zero otherwise. Sample input/output: Enter a string of digits to process or 'quit' to stop: 3294751 The sum of the digits in 3294751 is 31 The product of the digits in 3294751 is 7560 The string has no repeated digits. The highest digit in the given string is: 9 Enter a string of digits to process or 'quit' to stop: 454182 The sum of the digits in 454182 is 24 The product of the digits in 454182 is 1280 repeated digits. The string has Enter a string of digits to process or 'quit' to stop: 832015 The sum of the digits in 832015 is 19 The product of the digits in 832015 is 0 The string has no repeated digits. The highest digit in the given string is: 8 Enter a string of digits to process or 'quit' to stop: 22222 The sum of the digits in 22222 is 10 The product of the digits in 22222 is 32 The string has repeated digits. Enter a string of digits to process or 'quit' to stop: quit
Expert Answer:
Answer rating: 100% (QA)
Python def processStrdigits digitslist intdigit for digit in digits digitsum su... View the full answer
Related Book For
Computer Organization And Design The Hardware Software Interface
ISBN: 9780123747501
4th Revised Edition
Authors: David A. Patterson, John L. Hennessy
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
I recently heard my neighbor discussing how one of our other neighbors lost his job. My neighbor assumed that the person who lost his job was probably lazy or not smart enough for the job, without...
-
A toroidal solenoid (see Example 28.10) has inner radius r1 = 15.0 cm and outer radius r2 = 18.0 cm. The solenoid has 250 turns and carries a current of 8.50 A. What is the magnitude of the magnetic...
-
A TiW layer is deposited on a substrate using a sputtering tool. Table 6E.14 contains layer thickness measurements (in angstroms) on 20 subgroups of four substrates. (a) Setup x and R control charts...
-
The Anchor Glass Container Corporation and its parent company, Consumers Packaging, Inc. (CPI), entered into a series of agreements with Encore Glass, Inc., to supply glass containers of a specific...
-
Haver Company currently produces component RX5 for its sole product. The equipment that is used to produce RX5 must be replaced, and management must decide whether to replace the equipment or buy RX5...
-
Phelps competed at the Olympics. He won several gold medals and cash prizes, all worth $300,000. In addition, in the year that Phelps competed in the Olympics, he received several commercial...
-
Sweet Acacia Ranch & Farm is a distributor of ranch and farm equipment. Its products include small tools, power equipment for trench-digging and fencing, grain dryers, and barn winches. Most...
-
Why is it important to value a company? 2. What are the business valuation approaches? 3. How is a company valued through discounted free cash flow? 4. What is the purpose of the WACC in determining...
-
Which island has The brain gain is an increase in overall educational attainment in the Caribbean the potential of returnees to contribute to the social and economic development of their home country...
-
It appears that there have been more IPOs taking place in other countries than in the US in recent times. Which country's Stock Exchange, outside the US, has experienced the highest value and volume...
-
During production, when products are being produced each capitalist looks to lower their cost of production including lowering overhead cost and wages in order to increase profits. If every...
-
As the real value of the home currency increases substantially, as happened to the US dollar in the mid 1980s, MNCs which are exporting from the US to the rest of the world have one or more options...
-
solve the following e 3 x (lux) doc.
-
In the film "Frozen" (2013), what you determined the film portrayed regarding self-image, stereotypes, loaded words and heroes?
-
Where are the olfactory sensory neurons, and why is that site poorly suited for their job?
-
Using online or library resources, identify a set of standard benchmarks for applications in the table. Why do standard benchmarks help? Benchmarks play an important role in evaluating and selecting...
-
For each application, would increasing disk rotation speed improve performance? Explain your answer. Ultimately, storage system design requires consideration of usage scenarios as well as disk...
-
In the following problems, you will compare code written using the ARM and MIPS instruction sets. The following table shows code written in the ARM instruction set. What is the total number of ARM...
-
What is overdraft protection? Are all checking account holders automatically enrolled?
-
Although the basic principles of personal finance are the same for men and women, what are the social and demographic factors that make these decisions especially important for women?
-
Define net asset value. When is the net asset value of a mutual fund calculated?
Study smarter with the SolutionInn App