the square formed of stars
We will use the rows and columns of a matrix system to print our pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pattern1(): | |
# loop for rows | |
for x in range(1, 6): # can also take reverse (5, 0, -1) | |
# loop to print stars | |
for y in range(1, 6): # can also take in revers (5, 0, -1) | |
print("*", end=" ") | |
# after printing stars | |
print() # move to next line | |
# end = " " this will prevent print function to move to next line | |
# range() you can take any numbers to create a range of 5 numbers | |
# -ve range example showed you will in our next patterns | |
pattern1() |
Pattern 1
Reviewed by Leaf Code
on
August 09, 2020
Rating:

No comments: