Question: Python Problem 6 Write a function hourglass that takes a positive integer parameter n, and then, using print statements, draw an hourglass shape of 2n

 Python Problem 6 Write a function hourglass that takes a positive

Python

Problem 6 Write a function hourglass that takes a positive integer parameter n, and then, using print statements, draw an hourglass shape of 2n lines, made of asterisks. For example, the call hourglass (4) should display the following Some hints: To make the hourglass shape, you'll have to print an appropriate number of spaces (to indent the stars), followed by an appropriate number of asterisks. If you know how many spaces and how many stars, you can use a statement like the following: print (numspaces+numasterisks"") . You'll have to carefully consider how many spaces and how many asterisks to print at each line. What is the relationship between n and the number of asterisks printed at the widest point? What is the relationship between the numbers of asterisks at a given line and the number of asterisks at the next line? What is the relationship between the number of spaces an a given line and the number of spaces at the next line It may be helpful to draw an hourglass by hand for n-5 in order to help visualize the mathematical relationships of the various parts Because of the symmetric nature of the picture (i.e. it gets narrower, then wider), you may want to consider using two separate loops: one for the narrowing part, another for the widening part. First write one, then the other

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!