Basic Star Pattern Programming
1) Square Star Pattern
****
****
****
****
row = int(input())
for i in range(row):
print("*"*row)
2) Hollow Square Star Pattern
****
* *
* *
****
row = int(input())
for i in range(row):
if(i==0 or i==row-1):
print("*"*row)
else:
print("*" + " "*(row-2) + "*")
3) Rhombus Star pattern
****
****
****
****
row = int(input())
for i in range(row):
print(" "*i + "*"*row)
4) Rectangle Star Pattern
*******
*******
*******
row = int(input())
col = int(input())
for i in range(col):
for j in range(row):
print("*", end="")
print()
5) Hollow Rectangle Star Pattern
******
* *
* *
******
row = int(input()) col = int(input()) for i in range(col): for j in range(row): if(j==0 or j ==row-1 or i ==0 or i ==col-1): print("*", end="") else: print(" ", end="") print()
6) Parallelogram Star Pattern
******
******
******
******
row = int(input()) col = int(input()) for i in range(row): for j in range(1,i+1): print(" ",end="") for j in range(0,col): print("*",end="") print()
7) Mirrored Star rhombus star pattern
****
****
****
****
row = int(input()) j = row-1 for i in range(row): print(" "*j + ("*"*row)) j -= 1
8) Triangular Star Pattern
*
**
***
****
*****
row = int(input()) for i in range(1,row+1): print("*"*i)
9) Pyramid Star Pattern
*
***
*****
*******
row = int(input())
j = row-1
for i in range(1,row+1):
print(" "*j + "*"*(i + (i-1)) + " "*j)
j -= 1
10) Hollow Pyramid Star Pattern
*
* *
* *
*******
row = int(input()) j = row-1 for i in range(1,row+1): if(i==1 or i== row): print(" "*j + "*"*(i + (i-1)) + " "*j) else: print(" "*j + "*" + " "*(i + (i-3)) + "*" + " "*j) j -= 1
11) Inverted Pyramid Star Pattern
*******
*****
***
*
row = int(input())
j = row
for i in range(row):
print(" "*i + "*"*(j + (j-1)) + " "*i)
j -= 1
12) Inverted Hollow Pyramid Star Pattern
*******
* *
* *
*
row = int(input())
j = row
for i in range(row):
if(i==0 or i==row-1):
print(" "*i + "*"*(j + (j-1)) + " "*i)
else:
print(" "*i + "*" + " "*(j + (j-3)) + "*" + " "*i)
j -= 1
13) Half Diamond Star Pattern
*********
row = int(input()) for i in range(1,row+1): print("*"*i) k = row for j in range(1, row): print("*"*k) k -= 1
Half Diamond Star Pattern Inverted
*
********
row = int(input()) j = row -1 for i in range(1,row+1): print(" "*j + "*"*i) j -= 1 k = row-1 for j in range(1, row): print(" "* j + "*"*k) k -= 1
14) Diamond Star Pattern
*
***
*****
***
*
row = int(input()) j = row-1 for i in range(1,row): print(" "*j + "*"*(i + (i-1)) + " "*j) j -= 1 k = row for i in range(row): print(" "*i + "*"*(k + (k-1)) + " "*i) k -= 1
Comments
Post a Comment