Write a Python program that has three functions that do the following: 1- Function: main No...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python program that has three functions that do the following: 1- Function: main No parameters. Return: None Processing: Print welcome message. Call ask_for_int() to get an int that the user has entered (use low of 0 and high of 996). Call factorial, passing in the integer that the user entered. Ask the user if they would like to loop again. If so, loop again, if not, then quit the loop. Print goodbye message. 2- Function: ask_for_int Parameters: low, high Return: int the user entered Processing: Ask the user to enter an integer. Using exception handling, check to see if user entered a valid int. If not int, print error message and loop again. If valid int, also check to see if within low / high range. If not in range, print error message and loop again. Return valid integer the user entered. 3- Function name: factorial Parameters: num Return: the factorial answer Processing: Compute the factorial using recursion. Do not use a loop within this function. Must use recursion. Watch the videos provided to get some clues on how to write this function. Activate V Go to Setting Write a Python program that has three functions that do the following: 1- Function: main No parameters. Return: None Processing: Print welcome message. Call ask_for_int() to get an int that the user has entered (use low of 0 and high of 996). Call factorial, passing in the integer that the user entered. Ask the user if they would like to loop again. If so, loop again, if not, then quit the loop. Print goodbye message. 2- Function: ask_for_int Parameters: low, high Return: int the user entered Processing: Ask the user to enter an integer. Using exception handling, check to see if user entered a valid int. If not int, print error message and loop again. If valid int, also check to see if within low / high range. If not in range, print error message and loop again. Return valid integer the user entered. 3- Function name: factorial Parameters: num Return: the factorial answer Processing: Compute the factorial using recursion. Do not use a loop within this function. Must use recursion. Watch the videos provided to get some clues on how to write this function. Activate V Go to Setting
Expert Answer:
Related Book For
Computer Architecture A Quantitative Approach
ISBN: 978-0123704900
4th edition
Authors: John L. Hennessy, David A. Patterson
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...
-
An employer has asked you to develop a game in a Java program that needs to select a number at random between 1 to 10. Then, the user will be prompted to enter a number between 1 to 10 and, if it...
-
Perpetual inventory using FIFO Beginning inventory, purchases, and sales for Item Zeta9 are as follows: Oct. 1 Inventory 37 units @ $19 Oct. 7 Sale Oct. 15 Purchase Oct. 24 Sale Assuming a perpetual...
-
1. What evidence did the plaintiff offer to establish standing to enforce the note? Explain. 2. What might have been the result if the assignments of the note had ended with the indorsement on the...
-
Discuss how economics plays a vital role in shaping public discussion in the following policy areas: Household taxation Business taxation Import taxation (tariffs) Provide several examples of how...
-
Find the z-score that has 93.1865% of the distributions area to its left. Find the indicated z-score.
-
A firm is contemplating shortening its credit period from 40 to 30 days and believes that, as a result of this change, its average collection period will decline from 45 to 36 days. Bad-debt expenses...
-
Explain how high-pressure distillation systems influence the volatility of compounds and discuss the engineering challenges associated with operating at elevated pressures .
-
Calculate the following variances and indicate whether each variance is favorable or unfavorable: 1. Volume Variance 2. Total Variance Expected Treatments= 1,000 Standard Cost Profile Lab Treatment...
-
Compare leasing and buying fixed assets. Describe the difference between an operating lease and a finance lease. Explain the importance of good supplier relationships. Explain when alternative...
-
Ivan, an industrial engineering student, is working on a homework problem for Engineering Economy. He needs to calculate the PW at 12 percent of a cash flow series with \(\$ 1,000\) at \(t=3, \$...
-
How is the BlackScholesMerton formula for valuing a European option on a non-dividend-paying stock adjusted to value a European option on an asset providing a known dividend yield?
-
An inline filter has an estimated life of 9 years. By adding a purifier to the filter, savings of \(\$ 300\) in annual operating costs can be obtained. Annual interest on capital is 8 percent....
-
With a state-space structure, prove that, by choosing \(a_{11}=a_{22}=\cos \left(\omega_{0} ight)\) and \(a_{21}=\) \(-a_{12}=-\sin \left(\omega_{0} ight)\), the resulting oscillations in states...
-
Determine whether the polynomials below can be the denominator of a causal stable filter: (a) \(z^{5}+2 z^{4}+z^{3}+2 z^{2}+z+0.5\) (b) \(z^{6}-z^{5}+z^{4}+2 z^{3}+z^{2}+z+0.25\) (c) \(z^{4}+0.5...
-
During the year equipment originally costing $25,000 was sold for $20,000. A gain on sale of $2,000 was recorded on the income statement (included in Sales). Also new equipment was purchased.
-
l ask this second time correnct answer is 38,01 can we look pls Consider a non-conducting rod of length 8.8 m having a uniform charge density 4.5 nC/m. Find the electric potential at P, a...
-
Exercise 4.3 asks you to add the Owned state to the simple MSI snooping protocol. Repeat the question, but with the simple directory protocol above.
-
Assume that you now have access to a disk that has twice the capacity, for the same price. If you continue to design only for reliability, how would you change the configuration of your storage...
-
Exercise 4.3 asks you to add the Owned state to the simple MSI snooping protocol. Repeat the question, but with the switched snooping protocol above.
-
On 1 January 2023, Blue Jay Ltd revalued land from \(\$ 300000\) to \(\$ 500000\). On 1 January 2024, the company subsequently revalued the land to \(\$ 420000\). And on 1 January 2025 , the company...
-
The following data from Lyre Ltd's accounts relates to two assets at 30 June 2023. At 30 June 2023 Lyre Ltd decides to adopt the revaluation model for both these assets. On this date land has a fair...
-
Crane Ltd has proposed that the company adopt the revaluation model for fixed assets. Some of these assets are hard to obtain and certain items have increased in value in the current period, however...
Study smarter with the SolutionInn App