# Print Number Pattern in Python

## Print Number Pattern in Python

You can write this program using For Loop in Python and while loop in Python. Follow same concept like C programming only change syntax. Here First outer loop is used to handle number of rows and Inner nested loop is used to handle the number of columns.

### Row and Column for Print Number Patter in Python

To print any pattern we need number of rows and column. Outer loop tells us the number of rows used and inner loop tells us the column used to print pattern. ### Steps to Print Number Patter in Python

• Accept the number rows user want to print in the pattern.
• Iterate those number using outer for loop to handle the number of rows.
• Inner loop to handle the number of columns. Inner loop iteration depends on the values of the outer loop.
• Print start, number, asterisk, Pyramid and diamond pattern using the print() function.
• Add a new line after each row, i.e. after each iteration of outer for loop so you can display pattern appropriately.

## Print Number Pattern in Python

```for i in range(7):
print (str(i) + " ")*i
```

```
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
```

## Print number Pattern in Python

```lastNumber = 6
for row in range(1, lastNumber):
for column in range(1, row + 1):
print(column, end=' ')
print("")
```

```
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
```

## Print Number Pattern in Python

```currentNumber = 1
stop = 2
rows = 3 # Rows you want in your pattern
for i in range(rows):
for column in range(1, stop):
print(currentNumber, end=' ')
currentNumber += 1
print("")
stop += 2
```

```
1
2 3 4
5 6 7 8 9
```

## Print number Pattern in Python

```for i in range(1, 8 + 1):
for j in range(i, 0, -1):
print(j),
print("")
```

```
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
```

## Print number Pattern in Python

```for i in range(1, 9):
for i in range(-1+i, -1, -1):
print(format(2**i, "4d")),
print
```

## Output

```
1
2 1
4 2 1
8 4 2 1
16 8 4 2 1
32 16 8 4 2 1
64 32 16 8 4 2 1
128 65 32 16 8 4 2 1
```

## Print number Pattern in Python

```for i in range(1, 9):
for i in range(0,i,1):
print(format(2**i, "4d")),
for i in range(-1+i, -1, -1):
print(format(2**i, "4d")),
print
```

## Output

```
1
1 2 1
1 2 4 2 1
1 2 4 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
1 2 4 8 16 32 64 32 16 8 4 2 1
1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
```

## Print number Pattern in Python

```for i in range(1, 9):
n = 34-(5*(i-1))+1
print(" ")*n,
for i in range(0,i,1):
print(format(2**i, "4d")),
for i in range(-1+i, -1, -1):
print(format(2**i, "4d")),
print
```

## Output

```
1
1 2 1
1 2 4 2 1
1 2 4 8 4 2 1
1 2 4 8 16 8 4 2 1
1 2 4 8 16 32 16 8 4 2 1
1 2 4 8 16 32 64 32 16 8 4 2 1
1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
```