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.
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
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
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
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
Nested for loop in Python language
PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…
PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…
5 methods to add two numbers in Java In this tutorial, we will discuss the…
Write a function or method to convert C into F -Entered by the user In…
How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…
Program for Celsius into Fahrenheit conversion In this tutorial, we will discuss the concept of…