We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4c2b38c commit 7ed335eCopy full SHA for 7ed335e
1 file changed
06 Patterns2/Pyramid Number Pattern.py
@@ -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
18
19
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