PYTHON PROGRAM TO PRINT Square Pattern of star
* * * *
* * * *
* * * *
* * * *
We can generate a square pattern using for loop and range() function. Number of lines to be printed will be taken from user.
Python program to print square pattern of star.
number_of_lines = int(input("Please Enter number of lines:"))
for i in range(number_of_lines):
for i in range(number_of_lines):
print('*', end = ' ')
print()
Program Output - 1
Please Enter number of lines:3
* * *
* * *
* * *
* * *
* * *
Program Output - 2
Please Enter number of lines:4
* * * *
* * * *
* * * *
* * * *
No comments:
Post a Comment