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
-
Two assistants have been employed, and both fit in well, proving immediately popular in the office. With one exception, the team culture is excellent. You have scheduled another meeting with Jo,...
-
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...
-
Dozier Company produced and sold 1,000 units during its first month of operations. It reported the following costs and expenses for the month: Direct materials Direct labor $ 79,000 $ 40,000 Variable...
-
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...
-
Discuss in-depth the Indian agricultural market, the ways to enter in agricultural market and their respective strategy.
-
The Drosophila genes vg (vestigial wings) and cn (cinnabar eyes) are located at 67.0 and 57.0, respectively, on chromosome 2. A female from a homozygous strain of vestigial flies was crossed with a...
-
Omaha, Inc., recorded certain capital stock transactions shown in the following journal entries: (1) issued common stock for \(\$ 40\) cash per share, (2) purchased treasury shares at \(\$ 50\) per...
-
Dr. Susan Sweeney, a Providence, Rhode Island, psychologist, specializes in treating patients who are agoraphobic (i.e., afraid to leave their homes). The following table indicates how many patients...
-
During 2023, your clients, Mr. and Mrs. Howell, owned the following investment assets: Investment Assets Date Acquired Purchase Price Broker's Commission Paid at Time of Purchase 300 shares of IBM...
-
You are trying to evaluate whether an existing, idle distillation column can be used for a separation for which it was not originally designed. Answer the following questions about this column: a....
-
Una planta de manufactura que elabora camisas de vestir desea establecer por medio de los sistemas de tiempos predeterminados MTM-1 la capacidad instalada semanal (cuota de produccin al 100%) en la...
-
1. A 2.3-kg hockey puck moving at 24 m/s is caught and held by a 75-kg goalie at rest. With what speed does the goalie slide on ice?
-
Sometimes students believe that taking the time to prepare a complete and carefully design research proposal is something to be preached, but not really practice. Identify at least two different...
-
Discuss how political allusions are employed to reveal the author's allegiance or ideological leanings.
-
Four field hockey players are running down the field at the same speed. Player 1 weighs 140 lbs and is running toward the north goal, player 2 weighs 130 lbs and is running toward the south goal,...
-
What is the cost of goods manufactured for 2024? Beginning finished goods, 1/1/2024 Ending finished goods, 12/31/2024 Cost of goods sold Sales revenue Operating expenses $84,000 79,000 306,000...
-
Briefly summarize the major sources of environmental law, the litigation (court cases) process, and the way in which environmental agencies enforce environmental law. How are states and...
-
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...
-
Oligopolists may charge a price lower than the profit-maximizing price to _________ new firms from entering the market. This strategy will be effective when new firms face _________ costs than...
-
In the traditional prisoners dilemma, a(n) _________ matrix is used to illustrate the various possibilities and results for the two parties.
-
In _________, each firm sets its policy without consulting other firms.
Study smarter with the SolutionInn App