Write a Python Program To Print a Diamond Shape Pattern With * Upto N Number Of Rows

Tech Programmer
0
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(1halfRow+1):
  for j in range(1space+1):
    print(end=" ")
  space = space-1
  for j in range(2*i-1):
    print(end="*")
  print()
space = 1
for i in range(1halfRow):
  for j in range(1space+1):
    print(end=" ")
  space = space+1
  for j in range(12*(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 :



Post a Comment

0Comments
Post a Comment (0)

Featured Highlighted Categories

You'll discover all of the most up-to-date bring innovative here.

Python List theory with List Programs
Get complete python lists theory and list basic and insane programs for your practice.
CBSE SAMPLE PAPERS
Get CBSE sample and question papers of last 7 years with answers to get best practice for your Board Exams
Python String theory and String Programs
Python strings complete theory with illustrations and practice programs for free