Printing Pyramid Pattern in Python
Simple Pyramid Pattern :
A simple Pyramid pattern can create by using only one for a loop. In simple pyramid pattern, we only use one for loop and multiply iteration with stars.
for i in range(6): print("* "*i)
Result:
Real Pyramide Pattern: This pyramids shape look loke real pyramids. In this program we use for loop for rows and the variable spc is for the pyramid indentation.
90 Degree Simple Mirror Pyramid Pattern :
spc = 5 for i in range(6): print(" "*spc+"* "*i) spc= spc-1
Result:
Simple Mirror Pyramid Pattern :
spc = 5 for i in range(6): print(" "*spc+"* "*i) spc= spc-1
Result:
90 Degree rotation of Simple Pyramid Pattern :
spc = 5 for i in range(6): print("* "*spc) spc= spc-1
Result:
90 Degree rotation of Real Pyramid Pattern :
spc = 0 star = 6 for i in range(6): print(" "*spc+"* "*star) star = star-1 spc= spc+1
Result:
spc = 0 star = 6 for i in range(6): print(" "*spc+"* "*star) spc= spc+1 star = star -1
Result:
0 Comments:
Post a Comment