Answer:
The program in Python is as follows:
numrows = int(input())
n = 0
for i in range(1, numrows + 1):
for j in range (1, (numrows - i) + 1):
print(end = " ")
while n != (2 * i - 1):
print("*", end = "")
n = n + 1
n = 0
print()
k = 1; n = 1
for i in range(1, numrows):
for j in range (1, k + 1):
print(end = " ")
k = k + 1
while n <= (2 * (numrows - i) - 1):
print("*", end = "")
n = n + 1
n = 1
print()
Step-by-step explanation:
This gets the number of rows
numrows = int(input())
This initializes the upper part of the diamonds
n = 0
The following iteration prints the spaces in each row
for i in range(1, numrows + 1):
for j in range (1, (numrows - i) + 1):
print(end = " ")
The following iteration prints * in the upper part of the diamond
while n != (2 * i - 1):
print("*", end = "")
n = n + 1
n = 0
This prints a new line
print()
The lower part of the diamond begins here
k = 1; n = 1
The following iterations print the spaces in each row
for i in range(1, numrows):
for j in range (1, k + 1):
print(end = " ")
k = k + 1
The following iteration prints * in the lower part of the diamond
while n <= (2 * (numrows - i) - 1):
print("*", end = "")
n = n + 1
n = 1
This prints a new line
print()