star pattern

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

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

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

 

 

C# program to print pascal triangle number pattern
PHP Full Pyramid pattern program
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.

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

1 month ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

9 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

9 months ago

Program for Celsius into Fahrenheit conversion

Program for Celsius into Fahrenheit conversion In this tutorial, we will discuss the concept of…

9 months ago