1. Star Pattern - 1
rows = int(input("Enter the number of rows:"))
for i in range(0, rows):
for j in range(0, i + 1):
print("*", end=' ')
print( )
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
2. Star Pattern - 2
rows = int(input("Enter the number of rows:"))
k = 2 * rows - 2
for i in range(0, rows):
for j in range(0, k):
print(end=" ")
k = k - 2
for j in range(0, i + 1):
print("* ", end="")
print( )
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
3. Star Pattern - 3
rows=int(input("Enter the number of rows:"))
m = (2 * rows) - 2
for i in range(0, rows):
for j in range(0, m):
print(end=' ')
m = m - 1 # decrementing m after each loop
for j in range(0, i + 1):
# printing full Triangle pyramid using stars
print('*' , end=' ')
print( )
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
4. Star Pattern - 4
rows = int(input("Enter the number of rows:"))
k = 2 * rows -2
for i in range(rows, -1, -1):
for j in range(k, 0, -1):
print(end='')
k = k + 1
for j in range(0, i + 1):
print('*', end=' ')
print( )
Output :-
Enter the number of rows: 8
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
5. Star Pattern - 5
rows = int(input("Enter the number of rows:"))
for i in range(0, rows):
for j in range(0, i + 1):
print("*", end=' ')
print("\r")
for i in range(rows, 0, -1):
for j in range(0, i - 1):
print("*", end=' ')
print( )
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
6. Star Pattern - 6
rows = int(input("Enter the number of rows:"))
i = 1
while i <= rows:
j = i
while j < rows:
print(' ', end=' ')
j += 1
k = 1
while k <= i:
print('*', end=' ')
k += 1
print()
i += 1
i = rows
while i >= 1:
j = i
while j <= rows:
print(' ', end=' ')
j += 1
k = 1
while k < i:
print('*', end=' ')
k += 1
print( )
i -= 1
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
7. Star Pattern - 7
rows = int(input("Enter the number of rows:"))
for i in range(0, rows):
for j in range(0, i + 1):
print("*", end=' ')
print(" ")
print(" ")
for i in range(rows + 1, 0, -1):
for j in range(0, i - 1):
print("*", end=' ')
print(" ")
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
8. Star Pattern - 8
rows = int(input("Enter the number of rows:"))
k = 2 * rows - 2
for i in range(0, rows):
for j in range(0, k):
print(end=" ")
k = k - 1
for j in range(0, i + 1):
print("* ", end="")
print( )
k = rows - 2
for i in range(rows, -1, -1):
for j in range(k, 0, -1):
print(end=" ")
k = k + 1
for j in range(0, i + 1):
print("* ", end="")
print( )
Output :-
Enter the number of rows: 8
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
9. Star Pattern - 9
rows = int(input("Enter the number of rows:"))
i = 1
while i <= rows:
j = rows
while j > i:
print(' ', end=' ')
j -= 1
print('*', end=' ')
k = 1
while k < 2 * (i - 1):
print(' ', end=' ')
k += 1
if i == 1:
print()
else:
print('*')
i += 1
i = rows - 1
while i >= 1:
j = rows
while j > i:
print(' ', end=' ')
j -= 1
print('*', end=' ')
k = 1
while k <= 2 * (i - 1):
print(' ', end=' ')
k += 1
if i == 1:
print()
else:
print('*')
i -= 1
Output :-
Enter the number of rows: 8
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
10. Star Pattern - 10
rows = int(input("Enter the number of rows:"))
i = 0
while i <= rows - 1:
j = 0
while j < i:
print('', end=' ')
j += 1
k = i
while k <= rows - 1:
print('*', end=' ')
k += 1
print()
i += 1
i = rows - 1
while i >= 0:
j = 0
while j < i:
print('', end=' ')
j += 1
k = i
while k <= rows - 1:
print('*', end=' ')
k += 1
print( )
i -= 1
Output :-
Enter the number of rows: 8
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
11. Star Pattern - 11
#Christmas Tree star pattern
rows = int(input("Enter the number of rows:")) #For number of rows...
t = int(input("Enter the number:"))
m = (2*rows) -2
for i in range(0, rows):
for j in range(0, m):
print(end=' ')
m = m-1
for j in range(0, i+1):
print("* ", end=' ')
print()
for k in range(t):
print(" "*(t-1)+"\t\t*")
Output :-
Enter the number of rows : 6
Enter the number : 3
*
* *
* * *
* * * *
* * * * *
* * * * * *
*
*
*
0 Comments