# Python Program to Print Square Number Pattern

Write a Python Program to Print Square Number Pattern using While Loop and For Loop with an example.

## Python Program to Print Square Number Pattern using For Loop

This Python program allows users to enter any side of a square. This side decides the number of rows and columns of a square. Next, this program use For Loop to print 1’s until it reaches to the user-specified rows, and columns.

```# Python Program to Print Square Number Pattern

side = int(input("Please Enter any Side of a Square  : "))

print("Square Number Pattern")

for i in range(side):
for i in range(side):
print('1', end = '  ')
print()```

If you want to print 0, please replace 1 in print statement with 0.

```# Python Program to Print Square Number Pattern

side = int(input("Please Enter any Side of a Square  : "))

print("Square Number Pattern")

for i in range(side):
for i in range(side):
print('0', end = '  ')
print()```
``````Please Enter any Side of a Square  : 10
Square Number Pattern
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0
>>> ``````

## Python Program to return Square Number Pattern using While Loop

In this Python square number pattern example, we just replaced the For Loop with While Loop.

```# Python Program to Print Square Number Pattern

side = int(input("Please Enter any Side of a Square  : "))
i = 0

print("Square Number Pattern")

while(i < side):
j = 0
while(j < side):
j = j + 1
print('5', end = '  ')
i = i + 1
print()```
``````Please Enter any Side of a Square  : 10
Square Number Pattern
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
5  5  5  5  5  5  5  5  5  5
>>> ``````

## Python Program to Display Square Number Pattern

This Python program asks the user to enter any number. Next, Python prints that number in a square pattern.

```## Python Program to Print Square Number Pattern

side = int(input("Please Enter any Side of a Square  : "))
number = int(input("Please Enter any Number  : "))

print("Square Number Pattern")

for i in range(side):
for i in range(side):
print(number, end = '  ')
print()
```
``````Please Enter any Side of a Square  : 12
Please Enter any Number  : 9
Square Number Pattern
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
9  9  9  9  9  9  9  9  9  9  9  9
>>> ``````