0% found this document useful (0 votes)
6 views2 pages

Triangular Pattern Programs

The document provides ten different triangular pattern programs written in Python, showcasing various shapes using stars, numbers, and alphabets. Each program is accompanied by a brief description of its output, including right-angled triangles, inverted triangles, pyramids, and Floyd's and Pascal's triangles. The examples illustrate fundamental programming concepts such as loops and functions.

Uploaded by

seemabhatia392
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Triangular Pattern Programs

The document provides ten different triangular pattern programs written in Python, showcasing various shapes using stars, numbers, and alphabets. Each program is accompanied by a brief description of its output, including right-angled triangles, inverted triangles, pyramids, and Floyd's and Pascal's triangles. The examples illustrate fundamental programming concepts such as loops and functions.

Uploaded by

seemabhatia392
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

10 Triangular Pattern Programs in Python

1. Right-Angled Triangle of Stars


for i in range(1, 6):
print("*" * i)

2. Inverted Right-Angled Triangle of Stars


for i in range(5, 0, -1):
print("*" * i)

3. Right-Aligned Triangle of Stars


for i in range(1, 6):
print(" " * (5 - i) + "*" * i)

4. Inverted Right-Aligned Triangle of Stars


for i in range(5, 0, -1):
print(" " * (5 - i) + "*" * i)

5. Pyramid Pattern of Stars


for i in range(1, 6):
print(" " * (5 - i) + "*" * (2 * i - 1))

6. Inverted Pyramid Pattern


for i in range(5, 0, -1):
print(" " * (5 - i) + "*" * (2 * i - 1))

7. Triangle of Numbers
for i in range(1, 6):
for j in range(1, i + 1):
print(j, end="")
print()

8. Triangle of Alphabets
for i in range(1, 6):
for j in range(65, 65 + i):
print(chr(j), end="")
print()

9. Floyd's Triangle
num = 1
for i in range(1, 6):
for j in range(i):
print(num, end=" ")
num += 1
print()

10. Pascal's Triangle


def factorial(n):
return 1 if n == 0 else n * factorial(n - 1)

for i in range(5):
print(" " * (5 - i), end="")
for j in range(i + 1):
val = factorial(i) // (factorial(j) * factorial(i - j))
print(val, end=" ")
print()

You might also like