415,732 views
1 vote
1 vote
Write a program which takes an integer input, n, from the user and prints a rectangle with a height of n by printing asterisks inside a for loop. You can set the other side of the rectangle 10 for simplicity. So, your program should print 10 asterisks at the top, 10 asterisks at the bottom, two asterisks each side for other cases so that inside the rectangle can be empty. You can achieve this by using if statements inside a for loop. Here are some three sample runs with n values, 5, 6, and 8.

User Sigex
by
3.3k points

1 Answer

7 votes
7 votes

Answer:

Step-by-step explanation:

The following code is written in Python and prompts the user for the height of the rectangle and finally loops through to create it

def makeRectangle(height):

height = int(input("What is the height of the Rectangle?"))

print("**********")

for x in range(height-2):

print("* *")

print("**********")

User Kieran Wood
by
3.1k points