Skip to content

Commit 7ed335e

Browse files
Create Pyramid Number Pattern.py
1 parent 4c2b38c commit 7ed335e

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'''
2+
Problem statement
3+
Print the following pattern for the given number of rows.
4+
5+
Pattern for N = 4
6+
1
7+
212
8+
32123
9+
4321234
10+
Input format : N (Total no. of rows)
11+
12+
Output format : Pattern in N lines
13+
14+
Sample Input :
15+
5
16+
Sample Output :
17+
1
18+
212
19+
32123
20+
4321234
21+
543212345
22+
'''
23+
24+
from math import *
25+
from collections import *
26+
from sys import *
27+
from os import *
28+
29+
## Read input as specified in the question.
30+
n = int(input())
31+
## Print output as specified in the question.
32+
33+
for i in range(1, n+1):
34+
for s in range(n-i):
35+
print(" ",end="")
36+
for j in range(i,0,-1):
37+
print(j, end="")
38+
for k in range(2,i+1):
39+
print(k, end="")
40+
print()
41+

0 commit comments

Comments
 (0)