Write a program to print pattern like :
2 1
3 21
4 3 2 1
5 4 3 2 1
Answers
Answered by
7
This pattern is exactly same as the pattern where 1 is also present.
For the pattern;
We use;
- for i in range(1, 6): ## The outer loop starting from 1 to 6. For deciding the number of rows.
- for j in range(i, 0, -1): # The inner loop for deciding the order of the column, i.e., when the value of "i" is 3, the value of "j" can get the values 3, 2, 1.
- print(j, end=' ') # We'll print "j".
- print()
Now for your pattern;
Here the value of "i" can be altered in the loop;
- for i in range(2, 6): ## The outer loop starting from 2 to 6. For deciding the number of rows.
- for j in range(i, 0, -1): # The inner loop for deciding the order of the column, i.e., when the value of "i" is 3, the value of "j" can get the values 3, 2, 1.
- print(j, end=' ') # Rest all will be same.
- print()
Attachments:
![](https://hi-static.z-dn.net/files/d79/2fe72ea8447ae946c4b0e9e93a1fec8d.jpg)
![](https://hi-static.z-dn.net/files/d4f/c4e49d57a215cf4517d78080bb555724.jpg)
Answered by
49
Similar questions