Star Hyphen Tricky Pattern Program in Python

And below Python concepts are used to print that patterns

  • For Loop
  • While Loop
  • if..else

1). Program to print left half diamond pattern using star(*) and hyphen(-) in Python

star hyphen combination pattern program in c
n = int(input("Enter the value n:"))
for i in range(0,n):
    for j in range(1,n-i):
        print(" ",end='')
    if (i % 2)==0:
        for k in range(0,i+1):
            print("*",end='')
    else:
        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='')
    if (i % 2)==0:
        for k in range(i,0,-1):
            print("-",end='')
    else:
        for k in range(i,0,-1):
            print("*",end='')
    print()
    
 

Output

left half diamond pattern using star and hyphen in c

2). Program to print right half diamond pattern using star(*) and hyphen(-) in Python

star hyphen combination pattern program in c
n = int(input("enter the value of n:"))
for i in range(1,n+1):
    if (i % 2)==0:
        for k in range(1,i+1):
            print("-",end='')
    else:
        for k in range(1,i+1):
            print("*",end='')
    print()
for i in range(n,1,-1):
    if (i % 2)==0:
        for k in range(i,1,-1):
            print("*",end='')
    else:
        for k in range(i,1,-1):
            print("-",end='')
    print() 

Output

right half diamond pattern using star and hyphen in C

3). Program to print Triangle pattern using star(*) and hyphen(-) in Python

star hyphen combination 3 pattern program in C
n = int(input("enter the value of n:"))
for i in range(0,n):
    for k in range(1,n-i):
        print(" ",end='')
    print("*",end='')
    for j in range(0,i-1):
        print("-",end='')
    for j in range(0,i):
        print("-",end='')
    if i>0:
        print("*",end='')
    print() 

Output

4). Program to print full diamond pattern using star(*) and hyphen(-) in Python

star hyphen combination full pattern program in c
n = int(input("enter the value of n:"))
for i in range(1,n+1):
    for k in range(0,n-i):
        print(" ",end='')
    if(i%2==1):
        for j in range(0,2*i-1):
            print("*",end='')
    else:
        for j in range(0,2*i-1):
            print("-",end='')
    print()
for i in range(n,1,-1):
    for k in range(n,i-1,-1):
        print(" ",end='')
    if(i%2==1):
        for j in range(2*i-2,1,-1):
            print("-",end='')
    else:
        for j in range(2*i-2,1,-1):
            print("*",end='')
    print() 

Output