Write a python program to print a Diamond Shape Pattern using any given(input) character

Tech Programmer
0

WRITE A PYTHON PROGRAM TO PRINT A DIAMOND SHAPE PATTERN USING ANY GIVEN(INPUT) CHARACTER. 


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

print(end="Enter any single Character: ")
ch = input()
chalength = len(ch)
if chalength==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=ch)
    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=ch)
    print()
else:
  print("\n error! more than 1 character used")


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


print(end="Enter any single Character: ")

ch = input()

chalength = len(ch)

if chalength==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=ch)

    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=ch)

    print()

else:

  print("\n error! more than 1 character used")


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