Hello friends,
I am back with an interesting program which can print an hollow pyramid.
This pyramid can be of any number of lines.
But after 10 lines the pyramid's shape will change due to inclusion of two digit numbers.
So, Just check out,
# This Program is created by Sanjay Majhi.
def hollow_pyramid(n):
s=" "
print n*s,sym
n-=1
p=1
for i in range(1,n+1):
if n!=1:
print n*s,sym+(p*s)+sym # concatenation is done to correct the spacing.
else:
print n*s,sym*(p+2)
p+=2
n-=1
n=input("Enter a number:-")
sym=raw_input("Enter a symbol:-")
hollow_pyramid(n)
Hope that you will understand the program.
Please share this post if you like it.
Get in touch with my blog to get more Python Programs.
In my next post you can see program to print filled pyramid.
No comments:
Post a Comment