Skip to content

Commit 4c2508e

Browse files
Pattern.py
1 parent da1cc4e commit 4c2508e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Pattern.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Python 3.x code to demonstrate star pattern
2+
3+
# Function to demonstrate printing pattern of numbers
4+
def numpat(n):
5+
6+
# initialising starting number
7+
num = 1
8+
9+
# outer loop to handle number of rows
10+
for i in range(0, n):
11+
12+
# re assigning num
13+
num = 1
14+
15+
# inner loop to handle number of columns
16+
# values changing acc. to outer loop
17+
for j in range(0, i+1):
18+
19+
# printing number
20+
print(num, end=" ")
21+
22+
# incrementing number at each column
23+
num = num + 1
24+
25+
# ending line after each row
26+
print("\r")
27+
28+
# Driver code
29+
n = 5
30+
numpat(n)

0 commit comments

Comments
 (0)