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:
Answered by
49
Similar questions