Diamond Pattern programs in Python that most asked in Interview

And below Python concepts are used to print that patterns

  • For Loop
  • While Loop
  • if..else

1). Program to print half pyramid pattern using star(*) in Python

solid right half diamond pattern program in C
n = int(input("enter the number of row for half diamond:"))
for i in range(0,n):
    for k in range(0,i+1):
        print("*",end='')
    print()
for i in range(n,0,-1):
    for j in range(i-1,0,-1):
        print("*",end='')
    print() 

Output

right half diamond pattern using star in c

2). Program to print left half diamond pattern using star(*) in Python

solid left half diamond pattern program in c
n = int(input("enter the number of row for half diamond:"))
for i in range(0,n):
    for j in range(0,n-i-1):
        print(" ",end='')
    for k in range(0,i+1):
        print("*",end='')
    print()
for i in range(n-1,0,-1):
    for j in range(n,i,-1):
        print(" ",end='')
    for k in range(i,0,-1):
        print("*",end='')
    print() 

Output

3). Program to print full diamond pattern using star(*) in Python

solid diamond using star program in c
n = int(input("enter the number of row for full diamond:"))
for i in range(0,n):
    for j in range(0,n-i-1):
        print(" ",end='')
    for k in range(0,2*i+1):
        print("*",end='')
    print()
for i in range(n-1,0,-1):
    for j in range(n,i,-1):
        print(" ",end='')
    for k in range(2*i-1,0,-1):
        print("*",end='')
    print() 

Output