Python Full Pyramid star pattern program

Python full Pyramid star pattern program

In this tutorial, we will discuss  the concept of Python full Pyramid star pattern program

In this post, we will learn how to create pyramid star pattern in Python language.

We can use for loop, while loop or do while loop to display different Pyramid star patterns.

Full Pyramid star pattern program – #1

Here, we will use for loop  and while loop to print  pyramid star patterns in this program

Program 1

# Python program to print full Pyramid pattern
rows=int(input("Enter the number of rows"))
print("print full Pyramid star pattern")
k=0
for i in range (1,rows+1):
    for space in range(1,(rows-i)+1):
        print(end="  ")
        
    while k!=(2*i-1):
        print("* ",end="")
        k+=1
    k=0
    print()

When the above code is executed, it produces the following result

Python Full Pyramid pattern program
Pyramid pattern

 

In the above program, First , we get the height of the Pyramid(rows) using input statements in python from the user, then the program is printed the pyramid pattern using for and while loop

 

Full Pyramid(inverted) star pattern program – #2

Program 2

Here, we will use for loop  to print  pyramid star patterns in this program

# Python program to print inverted full Pyramid pattern
rows=int(input("Enter the number of rows:"))
print("print full Pyramid star pattern")

for i in range (rows,1,-1):
    for space in range(0,(rows-i)):
        print("  ",end="")
    for j in range(i,(2*i-1)):
        print("* ",end="")
    for j in range(1,i-1):
        print("* ",end="")
    print()

When the above code is executed, it produces the following result

Python Full Pyramid star pattern program
Pyramid star pattern

 

In the above program, First , we get the height of the Pyramid(rows) using input statements in python from the user, then the program is printed the pyramid pattern using for loop

Similar post

Java Program to pyramid star Pattern

C Program to pyramid star Pattern

C++ Program to pyramid star Pattern

Java program to print combined Pyramid pattern

C program to print combined Pyramid pattern

C++ program to print combined Pyramid pattern

 

Suggested for you

For loop in Python language

While loop in Python language

Nested for loop in Python language

Operator n Python language

Data types in Python language

 

 

By Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Leave a comment

Your email address will not be published. Required fields are marked *

0Shares