Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Follow the requested format for the file name, program inputs, and program outputs. The output should match the input. Programming language:Python Question 4: Pyramid of

Follow the requested format for the file name, program inputs, and program outputs.

The output should match the input.

Programming language:Python

Question 4: Pyramid of Numbers [100 marks]

Why have civilizations in many parts of the world been built as pyramids? What makes pyramids so special? Do you know it is estimated that the Great Pyramid of Giza is built of 2.3 million stone blocks? There is a lot to know about pyramids and this assignment wants to motivate you to do so by writing a program, called PyNum, which draw a pyramid of numbers.

PyNum first ask the user about the pyramids height using the message 'What is the height of the pyramid? '. Lets 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. Lets 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.

https://www.icloud.com/photos/#040NUMgrtdf-RQ8pJEjLnmeHw

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

What do you think of the MBO program developed by Drucker?

Answered: 1 week ago