[Go to site: main page, start]

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

Python Pattern Printing Examples

The document contains six Python code snippets that generate various patterns using loops. These patterns include a simple star pyramid, an alphabet pyramid, a number pattern, an inverted star pattern, an inverted number pyramid in descending order, and an inverted pyramid of a digit. Each snippet prompts the user to enter the number of rows for the respective pattern.

Uploaded by

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

Python Pattern Printing Examples

The document contains six Python code snippets that generate various patterns using loops. These patterns include a simple star pyramid, an alphabet pyramid, a number pattern, an inverted star pattern, an inverted number pyramid in descending order, and an inverted pyramid of a digit. Each snippet prompts the user to enter the number of rows for the respective pattern.

Uploaded by

kcskncreels
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1)Simple * Pattern Pyramid

rows=int(input("Enter no of rows:"))

for i in range(0, rows):

for j in range(0, i + 1):

print("* ", end=" ")

print()

2)Simple Alphabet Pyramid

rows = int(input("Enter number of rows: "))

ascii_value = 65

for i in range(rows):

for j in range(i+1):

alphabet = chr(ascii_value)

print(alphabet, end=" ")

ascii_value += 1

print()

3) Simple Number Pattern

rows = int(input("Enter the number of rows: "))

for num in range(rows+1):

for i in range(num):

print(num, end=" ")

print()
4) Simple Inverted Program

rows = int(input("Enter the number of rows: "))

for i in range(rows + 1, 0, -1):

for j in range(0, i - 1):

print("* ", end=" ")

print()

5)Simple Inverted Number Pyramid in Descending Order

rows = int(input("Enter the number of rows: "))

for i in range(rows, 0, -1):

num = i

for j in range(0, i):

print(num, end=" ")

print()

6) Simple Inverted Pyramid of a Digit

rows = int(input("Enter the number of rows: "))

num = rows

for i in range(rows, 0, -1):

for j in range(0, i):

print(num, end=" ")

print()

You might also like