Welcome folks today in this blog post we will be printing square star pattern or any custom sybmol using for loop and while loop in python.
All the full source code of the application is given below.
Get Started
In order to get started you need to make an app.py
file and copy paste the following code
Printing Square Pattern Using For Loop
app.py
1 2 3 4 5 6 7 8 9 10 11 |
# Python Program to Print Square Star Pattern side = int(input("Please Enter any Side of a Square : ")) symbol = input("Enter the Sybmol") print("Square Star Pattern") for i in range(side): for i in range(side): print(symbol, end= ' ') print() |
Now if you execute the python
script by typing the below command as shown below
python app.py
Printing Square Pattern using While Loop
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# Python Program to Print Square Star Pattern side = int(input("Please Enter any Side of a Square : ")) i = 0 print("Square Star Pattern") while(i < side): j = 0 while(j < side): j = j + 1 print('*', end = ' ') i = i + 1 print('') |