;

Python Program to Print the Square Star Pattern


Tutorialsrack 16/05/2020 Python

In this Python program, we will learn how to print the square star pattern.

Here is the source code of the program to print the square star pattern.

Program 1: Python Program to Print the Square Star Pattern Using For Loop

Python Program to Print the Square Star Pattern Using For Loop
# Python Program to Print the Square Star Pattern Using For Loop

# Take the Input From the User
side = int(input("Enter any Side of a Square: "))

# Print the Output
print("Square Star Pattern") 

for i in range(side):
    for i in range(side):
        print('*', end = '  ')
    print()
Output

Enter any Side of a Square: 5

Square Star Pattern

*  *  *  *  *  

*  *  *  *  *  

*  *  *  *  *  

*  *  *  *  *  

*  *  *  *  * 

Program 2: Python Program to Print the Square Star Pattern Using While Loop

Python Program to Print the Square Star Pattern Using While Loop
# Python Program to Print the Square Star Pattern Using While Loop

# Take the Input From the User5
side = int(input("Enter any Side of a Square: "))

i = 0

# Print the Output
print("Square Star Pattern") 

while(i < side):
    j = 0
    while(j < side):      
        j = j + 1
        print('*', end = '  ')
    i = i + 1
    print('')   
Output

Enter any Side of a Square: 6

Square Star Pattern

*  *  *  *  *  *  

*  *  *  *  *  *  

*  *  *  *  *  *  

*  *  *  *  *  *  

*  *  *  *  *  *  

*  *  *  *  *  *  


Related Posts



Comments

Recent Posts
Tags