Square Patterns in python

Square Pattern Type-1 (Source Code)

for x in range(1,5):

    for y in range(1,5):

        print(“*”,end=” “) 

    print(“”)

Output

* * * *

* * * *

* * * *

* * * *

Square Pattern Type-2 (Source Code)

for x in range(1,5):

    for y in range(1,5):

        print(x,end=” “) 

    print(“”)

Output

1 1 1 1

2 2 2 2

3 3 3 3

4 4 4 4

Square Pattern Type-3 (Source Code)

for x in range(1,5):

    for y in range(1,5):

        print(y,end=” “) 

    print(“”)

Output

1 2 3 4

1 2 3 4

1 2 3 4

1 2 3 4

Leave a Comment

Your email address will not be published. Required fields are marked *