Write a Python Program To Print a Diamond Shape Pattern With * Upto N Number Of Rows ?
CODE FOR THE ABOVE PYTHON PROGRAM :
print(end="\nEnter Total Number Of Lines You Want In Your In Your Diamond Shape: ")
Size = int(input())
if Size%2==0:
halfRow = int(Size/2)
else:
halfRow = int(Size/2)+1
space = halfRow-1
for i in range(1, halfRow+1):
for j in range(1, space+1):
print(end=" ")
space = space-1
for j in range(2*i-1):
print(end="*")
print()
space = 1
for i in range(1, halfRow):
for j in range(1, space+1):
print(end=" ")
space = space+1
for j in range(1, 2*(halfRow-i)):
print(end="*")
print()
WRITTEN CODE FOR THE ABOVE PROGRAM :
print(end="\nEnter Total Number Of Lines You Want In Your In Your Diamond Shape: ")
Size = int(input())
if Size%2==0:
halfRow = int(Size/2)
else:
halfRow = int(Size/2)+1
space = halfRow-1
for i in range(1, halfRow+1):
for j in range(1, space+1):
print(end=" ")
space = space-1
for j in range(2*i-1):
print(end="*")
print()
space = 1
for i in range(1, halfRow):
for j in range(1, space+1):
print(end=" ")
space = space+1
for j in range(1, 2*(halfRow-i)):
print(end="*")
print()
OUTPUT :