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

Python Pyramid Pattern Code

The document contains a Python program that generates a pyramid pattern based on user-defined height. It prompts the user to enter the height and then prints a symmetrical pyramid followed by an inverted pyramid. The sample output demonstrates the program's functionality with a height of 7.

Uploaded by

halojuztn
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)
2 views2 pages

Python Pyramid Pattern Code

The document contains a Python program that generates a pyramid pattern based on user-defined height. It prompts the user to enter the height and then prints a symmetrical pyramid followed by an inverted pyramid. The sample output demonstrates the program's functionality with a height of 7.

Uploaded by

halojuztn
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

SOURCE CODE :

print('\n\t******PYRAMID PATTERN******\n')

height = int(input('Enter the height: '))

for i in range(height):

for j in range(height - i - 1):

print(' ', end='')

for j in range(i + 1):

print('*', end=' ')

print()

for i in range(height - 2, -1, -1):

for j in range(height - i - 1):

print(' ', end='')

for j in range(i + 1):

print('*', end=' ')

print()

SAMPE OUTPUT :

******PYRAMID PATTERN******

Enter the height: 7

**

***
****

*****

******

*******

******

*****

****

***

**

RESULT:

The program is successfully executed and verified.

You might also like