Table of contents
No headings in the article.
Patterns can be printed in python using simple for loops.
# First outer loop is used to handle the number of rows
# and the Inner nested loop is used to handle the number of columns.
# Manipulating the print statements, different number patterns, alphabet patterns, or star patterns can be printed.
# 1.printing a right angle triangle
for i in range(6):
for j in range(i):
print("*",end=" ")
print("\n")
#working expalained: in this loop the range of the first loop is set to 6 so, when it starts it first startts with 0 . when the flow of control goes to the 2nd loop the i being =0 it gets initialized once only .Thus printing 1 * and when the control gets out of the 2nd loop and goes back to the first one , it prints aspace for the next time i being 1 the 2nd loop gets initialized twice once for 1 being =0 and once for i being =1
#in this way each time the number of initializatons for 2nd loop kept on increasing with the 1st loop printing a space after each initialization .
# output
# *
# * *
# * * *
# * * * *
# * * * * *
# now for a 360* shift
space=6
for i in range(6,0,-1):
for j in range(i):
print("*",end=" ")
print("\n")
# here the initial point is 6 and the culminating point is 0 and the skipping step is set to -1 which means it runs in reverse order..
# output
# * * * * * *
# * * * * *
# * * * *
# * * *
# * *
# *