Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribedimage text in transcribed
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 3Problem 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 3

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

Students also viewed these Programming questions