program 2
program 2
2:
To write the python program to construct the following pattern using a nested
loop:
*
**
***
****
*****
****
***
**
*
Model 1:
n=5
Output:
*
**
***
****
*****
****
***
**
*
Model 2:
To write the python program to construct the following pattern using a nested
loop:
*****
* *
* *
* *
*****
n=5
for i in range(n):
for j in range(n):
if i == 0 or i == n - 1 or j == 0 or j == n - 1:
print("*", end="")
else:
print(" ", end="")
print()
Output:
*****
* *
* *
* *
*****