PyNum first ask the user about the pyramid's height using the message 'What is the height...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
PyNum first ask the user about the pyramid's height using the message 'What is the height of the pyramid?\n'. Let's call the pyramid height h, which should be a positive integer. Next, PyNum prints a pyramid of height h with numbers as following: • PyNum only prints a pyramid of numbers taller than 1 and shorter than 10. In other words, the user-provided input can not be smaller than 2 or greater than 9. • If the user-provided value is not in the specified range, PyNum will let the user know using the message 'PyNum cannot help you!! . On the top of the pyramid and in the first line, PyNum will always print 1, as depicted in Figure 4. • PyNume will print '1 2 3 ...n n-1 n-2... 1' in the nth line of pyramid. Let's assume h = 3, then, the first line of the pyramid will be 1. And second and third lines will be '1 2 1' and '1 2 3 2 1', respectively. • Note that there is a white space between each pair of consequent numbers. Figure 4 shows a sample output of PyNum for h = 9. You must name your code file q4.py and upload it to the HW1Q4: Pyramid of Numbers section on Gradescope. What is the height of the pyramid? 9 1 12 1 1 2 3 2 1 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 1 1 2 3 4 5 6 5 1 2 3 4 5 6 7 6 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 8 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 7 6 5 4 3 2 1 HNE 48 1 2 3 4 7 height = int(input('What is the height of the pyramid?\n')) for i in range(1, height+1): for j in range((height+1) - i): print(" ", end = " ") ~ M print("\n") PyNum first ask the user about the pyramid's height using the message 'What is the height of the pyramid?\n'. Let's call the pyramid height h, which should be a positive integer. Next, PyNum prints a pyramid of height h with numbers as following: • PyNum only prints a pyramid of numbers taller than 1 and shorter than 10. In other words, the user-provided input can not be smaller than 2 or greater than 9. • If the user-provided value is not in the specified range, PyNum will let the user know using the message 'PyNum cannot help you!! . On the top of the pyramid and in the first line, PyNum will always print 1, as depicted in Figure 4. • PyNume will print '1 2 3 ...n n-1 n-2... 1' in the nth line of pyramid. Let's assume h = 3, then, the first line of the pyramid will be 1. And second and third lines will be '1 2 1' and '1 2 3 2 1', respectively. • Note that there is a white space between each pair of consequent numbers. Figure 4 shows a sample output of PyNum for h = 9. You must name your code file q4.py and upload it to the HW1Q4: Pyramid of Numbers section on Gradescope. What is the height of the pyramid? 9 1 12 1 1 2 3 2 1 1 2 3 4 3 2 1 2 3 4 5 4 3 2 1 1 1 2 3 4 5 6 5 1 2 3 4 5 6 7 6 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 8 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1 7 6 5 4 3 2 1 HNE 48 1 2 3 4 7 height = int(input('What is the height of the pyramid?\n')) for i in range(1, height+1): for j in range((height+1) - i): print(" ", end = " ") ~ M print("\n")
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Experiential Activity. This chapter described some of the useful information that is available from the Employment and Training Administrations O*NET services (www.doleta.gov/programs/onet). Choose a...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Choose a topic that can be applied to one of the following economic concepts. (Possible curves: Lorenz curve, marginal product of labor curve, labor demand and supply curves, utility function and...
-
If Jody's records show $2,000 in investment by owner, $10,000 in net income, $5,000 in assets and $1,000 in owner's drawings. What is Jody's ending owner's equity on a statement of changes in owner's...
-
A 1.134-kg disk of radius 100 mm is attached to the yoke BCD by means of short shafts fitted in bearings at B and D. The 0.68-kg yoke has a radius of gyration of 75 mm about the x axis. Initially the...
-
For each of the situations listed, identify which of three principles (integrity, objectivity and independence, or due care) from the AICPA Code of Professional Conduct is violated. Assume all...
-
Calculate the mean for each of the following sets of data: a. 2, 2, 3, 5 b. 3, 5, 5, 7, 7, 8, 8, 11 c. 9, 6, 7, 5, 8, 7, 8, 9, 10, 8, 7 d. 11, 13, 14, 15, 16, 16, 16, 17, 18, 20, 22, 25 e. 2.57,...
-
Bloom Company management predicts that it will incur fixed costs of $160,000 and earn pretax income of $164,000 in the next period. Its expected contribution margin ratio is 25%. Use this information...
-
At December 3 1 , 2 0 2 2 , Samson Company reported Accounts Receivable of $ 1 0 5 , 0 0 0 and Allowance for Doubtful Accounts of $ 7 , 5 0 0 . On January 7 , 2 0 2 3 , Delilah, Inc. declares...
-
Hastings Company bases its variable overhead performance report on the actual direct labour- hours of the period. Data concerning the most recent year, which ended on December 31, are as follows:...
-
Student 10:57 PM Tue Sep 6 X Module 5: Kinematics in 2D v, (cm/s) v, (cm/s) 40 30 VE 20- 10 -1 (s) 1) A rocket-powered hockey puck moves on a horizontal frictionless table. The figure below shows the...
-
Explain why we use market values in determining a company's capital structure for capital budgeting?
-
If you were evaluating a US company (recall companies have perpetual lives), and determining its cost of equity using the CAPM, what bond would you use as a proxy for the risk-free rate?
-
A 60-year-old individual is ready to retire but has no pension plan. They have $800,000 in personal savings and a whole life insurance policy that pays $100,000 on death. The individual considers the...
-
Explain how the financial arrangement can influence the effectiveness of multinational capital budgeting?
-
if the current average rate of return for investments in the S&P 500 is 12%, and the guaranteed rate of return on short-term treasury bonds is 4%, Find the market risk premium.
-
Cash flows used in net present value and internal rate of returnanalyses ignore? ________. A. future increased sales B. depreciation expense C. future costsavings D. residual value
-
Avatar Financials, Inc., located on Madison Avenue, New York City, is a company that provides financial advice to individuals and small- to mid-sized businesses. Its primary operations are in wealth...
-
Real-time applications ____________. A. Use sequential access files B. Use batch processing C. Use random access files D. Seldom are interactive
-
Java is architecturally ____________. a. Neutral b. Oriented c. Specific d. Abstract
-
Within an event-driven program, a component on which an event is generated is the ____________. A. Performer B. Listener C. Source D. Handler
-
What are the numbers of observations in each of the five categories that rate the respondents level of job satisfaction?
-
Which of the seven store departments had the most customer visits, and what was this number?
-
How many individuals are in each of the five different credit card categories?
Study smarter with the SolutionInn App