File tree 1 file changed +57
-0
lines changed
1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ '''
2
+ Problem statement
3
+ Print the following pattern for the given number of rows.
4
+
5
+ Note: N is always odd.
6
+
7
+
8
+ Pattern for N = 5
9
+
10
+
11
+
12
+ The dots represent spaces.
13
+
14
+
15
+
16
+
17
+ Detailed explanation ( Input/output format, Notes, Images )
18
+ Constraints :
19
+ 1 <= N <= 49
20
+ Sample Input 1:
21
+ 5
22
+ Sample Output 1:
23
+ *
24
+ ***
25
+ *****
26
+ ***
27
+ *
28
+ Sample Input 2:
29
+ 3
30
+ Sample Output 2:
31
+ *
32
+ ***
33
+ *
34
+ '''
35
+
36
+ from math import *
37
+ from collections import *
38
+ from sys import *
39
+ from os import *
40
+
41
+ ## Read input as specified in the question.
42
+ n = int (input ())
43
+ ## Print output as specified in the question.
44
+ x = (n + 1 )// 2
45
+ for i in range (1 ,x + 1 ):
46
+ for s in range (x - i ):
47
+ print (" " , end = "" )
48
+ for j in range (2 * i - 1 ):
49
+ print ("*" , end = "" )
50
+ print ()
51
+ for j in range (x - 1 , 0 , - 1 ):
52
+ for s in range (x - j ):
53
+ print (" " , end = "" )
54
+ for j in range (2 * j - 1 ):
55
+ print ("*" , end = "" )
56
+ print ()
57
+
You can’t perform that action at this time.
0 commit comments