|
Small Python Program For Beginners |
In this article, we are going to write code to print out the mirror numbered pyramid using Python Programming. You can see that in the above-featured Image.
If you are looking for a Python Tutorial Series, then it's here
def triangle(n):
for i in range(n):
for j in range(n-i-1):
print(" ",end=' ')
for k in range(i,1,-1):
print(k, end=' ')
for l in range(1, i+1):
print(l,end=' ')
print('')
triangle(10)
The output of the program is:
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
7 6 5 4 3 2 1 2 3 4 5 6 7
8 7 6 5 4 3 2 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9
Comments
Post a Comment