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 local government levies an annual real property tax on the personal residence located at 123 Maple Drive. This tax is assessed on a calendar-year basis, and the homeowner must pay the tax before...
-
In the second half of 1997, the Indonesian rupiah devalued by 84% against the U.S. dollar. By how much has the dollar appreciated against the rupiah?
-
Lily Bakeries, located in Belgium, specializes in biscuit and cake products. Lily owns 75 percent of Hearty Foods, a French company acquired on January 1, 2013, for cash and stock totaling 150...
-
The Ombudsman Foundation is a private not-for-profit organization providing training in dispute resolution and conflict management. The Foundation had the following pre-closing trial balance at...
-
Task 2 Background You are working with Complete Business Services on the year-end adjustments for one of your clients, Curate Canvas Ltd. You are required to comply with the following information g...
-
What are the two elements that an employee must show to make a successful Title VII claim? Do you think the motivating factor standard is appropriate for discrimination claims based on national...
-
1. A semiconductor in its purest form is called a. Pure semiconductor b. Doped semiconductor c. Intrinsic semiconductor d. Extrinsic semiconductor 2. Valence orbit is the other form for a. Outer...
-
A congressman sent out questionnaires to 10,000 constituents to ask their opinions on a new health-care proposal. A total of 200 questionnaires were returned, and 70% of those responding supported...
-
A medical researcher wants to determine whether exercising can lower blood pressure. At a health fair, he measures the blood pressure of 100 individuals, and interviews them about their exercise...
-
Random-digit dialing is a sampling method in which a computer generates phone numbers at random to call. In recent years, caller ID has become popular. Do you think that caller ID increases the bias...
-
A medical researcher wants to determine whether exercising can lower blood pressure. She recruits 100 people with high blood pressure to participate in the study. She assigns a random sample of 50 of...
-
In a survey of 500 high school students, 60% of them said that they intended to go to college. In Exercises 1720, determine whether the number described is a statistic or a parameter.
-
Open the main page of the Uniform Crime Report. the FBI Crime Data Explorer and click on your state. What type of data did you research and find most interesting? Based on the theories you read about...
-
If the amplifier indicated by the box input impedance of oo, which of the following statements are true ? has an open loop gain as well as Feedback factor (\beta = 1/ R_1\) The feedback is voltage...
-
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
-
Question: A supervisor reprimanded an employee for eating in a restaurant when he should have been at work. Later, the employee showed up at the supervisor's office and shot him. Although the...
-
Question: Marko owned a cat and allowed it to roam freely outside. In the three years he had owned the pet, the animal had never bitten anyone. The cat entered Romi's garage. When Romi attempted to...
-
1. Benzaquin had a radio talk show in Boston. On the program, he complained about an incident earlier in the day, in which state trooper Fleming had stopped his car, apparently for lack of a proper...
Study smarter with the SolutionInn App