Q:

# Using the following code, write a Python Program to Print Triangle Number Patterns

Using the followings program, write a Python Program to Print 4 Triangle Number Patterns thoses mentioned bellow.

# This program displays a triangle pattern.
SIZE = 10
for r in range(1, SIZE):
for c in range(1, r + 1):
print('*', end='')
print()

Output: we need to modify the code to print same like these patterns:

====================

Pattern A:

1 2

1 2 3

1 2 3 4

1 2 3 4 5

1 2 3 4 5 6

1 2 3 4 5 6 7

1 2 3 4 5 6 7 8

1 2 3 4 5 6 7 8 9

Pattern B:

2 2

3 3 3

4 4 4 4

5 5 5 5 5

6 6 6 6 6 6

7 7 7 7 7 7 7

8 8 8 8 8 8 8 8

9 9 9 9 9 9 9 9 9

Pattern C:

9 9 9 9 9 9 9 9 9

8 8 8 8 8 8 8 8

7 7 7 7 7 7 7

6 6 6 6 6 6

5 5 5 5 5

4 4 4 4

3 3 3

2 2

Pattern D:

Pattern A:

This program displays a triangle pattern A
SIZE = 10
for r in range(1, SIZE):
counter=1
for c in range(1, r + 1):
print(counter, end=' ')
counter=counter+1
print()

Pattern B:

# This program displays a triangle pattern B
SIZE = 10
for r in range(1, SIZE):
for c in range(1, r + 1):
print(r, end=' ')
print()

Pattern C:

# This program displays a triangle pattern C
for r in range(9, 0,-1):
for c in range(r, 0,-1):
print(r, end=' ')
print()

Pattern D:

# This program displays a triangle pattern D
SIZE = 10
SIZEspaces=20
spaces=int(SIZEspaces/2)
for r in range(1, SIZE):
for space in range(1,spaces):
print(' ',end='')
SIZEspaces=SIZEspaces-1
spaces=int(SIZEspaces/2)
counter=1
for c in range(1, r + 1):
print(counter, end=' ')
counter=counter+1
print()