Write a Python Program to Print Rectangle Star Pattern using For Loop and While Loop with an example.
Python Program to Print Rectangle Star Pattern using For Loop
This Python program allows user to enter the total number of rows and columns for drawing rectangle. Next, we used Python Nested For Loop to print rectangle of stars.
# Python Program to Print Rectangle Star Pattern
rows = int(input("Please Enter the Total Number of Rows : "))
columns = int(input("Please Enter the Total Number of Columns : "))
print("Rectangle Star Pattern")
for i in range(rows):
for j in range(columns):
print('*', end = ' ')
print()

Python Program to Print Rectangle Star Example 2
This Python program allows the user to enter his/her own character. Next, it prints a rectangle of the user-specified character. For more, visit the Python star pattern programs.
# Python Program to Print Rectangle Star Pattern
rows = int(input("Please Enter the Total Number of Rows : "))
columns = int(input("Please Enter the Total Number of Columns : "))
ch = input("Please Enter any Character : ")
print("Rectangle Star Pattern")
for i in range(rows):
for j in range(columns):
print('%c' %ch, end = ' ')
print()
Please Enter the Total Number of Rows : 15
Please Enter the Total Number of Columns : 18
Please Enter any Character : $
Rectangle Star Pattern
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
>>>
Python Program to Print Rectangle of Stars using While Loop
This Python rectangle of stars program is the same as the first example. However, we replaced the Python For Loop with a Python While Loop.
# Python Program to Print Rectangle Star Pattern
rows = int(input("Please Enter the Total Number of Rows : "))
columns = int(input("Please Enter the Total Number of Columns : "))
print("Rectangle Star Pattern")
i = 0
while(i < rows):
j = 0
while(j < columns):
print('*', end = ' ')
j = j + 1
i = i + 1
print()
Please Enter the Total Number of Rows : 15
Please Enter the Total Number of Columns : 20
Rectangle Star Pattern
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
>>>
Also Read
- Python Program to Print Hollow Inverted Pyramid Star Pattern
- Python Program to Print Hollow Rectangle Star Pattern