Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Python Programs To Print Different Patterns

Uploaded by

shailenderojha
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)
12 views

Python Programs To Print Different Patterns

Uploaded by

shailenderojha
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/ 8

Python

Patterns!!!

By @engineer_bhaiya_yt
1. Right-angled Triangle

rows = 5
for i in range(1, rows + 1):
print("*" * i)

*
**
***
****
*****
2. Inverted Right-angled Triangle

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

*****
****
***
**
*
3. Pyramid Pattern python

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

*
***
*****
*******
*********
4. Diamond Pattern

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

*
***
*****
*******
*********
*******
*****
***
*
5. Number Pattern

rows = 5
for i in range(1, rows + 1):
for j in range(1, i + 1):
print(j, end="")
print()

1
12
123
1234
12345
6. Pascal’s Triangle

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

1
1 1
121
1331
14641
SAVE THIS POST
JOIN US ON TELEGRAM

We Post Free Data Science & Analytics material ,


Courses and Daily Job Notifications

JOIN USING LINK IN BIO

You might also like