Write a Python program to create the following pattern
**
***
****
*****
****
***
**
*
Here you can use for loop to create the first 4 lines.
for i in range (2,6):
print ("*" * i)
The output of this section is as follows.
**
***
****
*****
The while loop can be used to create stars one after the other, one after the other.
x = 5
while (x> 0):
x = x-1
print ('*' * x)
The output of this code is as follows.
****
***
**
*
Accordingly, the complete pattern can be created as follows by executing the two codes mentioned above simultaneously.
for i in range (2,6):
print ("*" * i)
x = 5
while (x> 0):
x = x-1
print ('*' * x)
The output of this complete code is as follows.
**
***
****
*****
****
***
**
*
Click here to download the Sinhala translation
0 Comments