0% found this document useful (0 votes)
5 views8 pages

L11-L13 Different Types of Patterns

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

L11-L13 Different Types of Patterns

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Different Types of Patterns

. Square Pattern in Python

# Square pattern program

# Create a list of rows


for i in range(0, 5):
# Create a list of columns
for j in range(0, 5):
print("*", end="")
print()
Hollow Square Pattern

# hollow square pattern


size = 5
for i in range(size):
for j in range(size):
# print * completely in first and last row
# print * only in first and last position in other rows
if i == 0 or i == size - 1 or j == 0 or j == size - 1:
print('*', end='')
else:
print(' ', end='')
print()
Left Triangle Star Pattern In Python

# Left triangle star pattern


n=5

for i in range(1, n+1):


# internal loop run for i times
for k in range(1, i+1):
print("*", end="")
print()
Right Triangle Star Pattern In Python

# right triangle star pattern


size = 5
for i in range(size):
for j in range(1, size - i):
print(" ", end="")
for k in range(0, i + 1):
print("*", end="")
print()

You might also like