File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ rows = int(input("Enter the number of rows: "))
2
+
3
+ # It is used to print the space
4
+ k = 2 * rows - 2
5
+ # Outer loop to print number of rows
6
+ for i in range(0, rows):
7
+ # Inner loop is used to print number of space
8
+ for j in range(0, k):
9
+ print(end=" ")
10
+ # Decrement in k after each iteration
11
+ k = k - 1
12
+ # This inner loop is used to print stars
13
+ for j in range(0, i + 1):
14
+ print("* ", end="")
15
+ print("")
16
+
17
+ # Downward triangle Pyramid
18
+ # It is used to print the space
19
+ k = rows - 2
20
+ # Output for downward triangle pyramid
21
+ for i in range(rows, -1, -1):
22
+ # inner loop will print the spaces
23
+ for j in range(k, 0, -1):
24
+ print(end=" ")
25
+ # Increment in k after each iteration
26
+ k = k + 1
27
+ # This inner loop will print number of stars
28
+ for j in range(0, i + 1):
29
+ print("* ", end="")
30
+ print("")
You can’t perform that action at this time.
0 commit comments