Hello friends,
Today I made a new program which prints a pyramid of given length.
In my previous post a I told you about how to print a hollow pyramid, and today I made some changes in the program to print a filled pyramid.
So, let's check out,
def pyramid(len):
spac_len=len
pyramid_width=1
i=1
while i<=len:
#First determine spacing then pyramid width
print " "*spac_len,str(i)*pyramid_width
pyramid_width+=2
spac_len-=1
i+=1
len=input("Enter lenth of pyramid:-")
pyramid(len)
The program is somewhat complicated for a beginner but you will understand.
Get in touch with my blog to get new programs.
No comments:
Post a Comment