Python Full Pyramid star pattern program
- Home
- pyramid triangle
- Python Full Pyramid star pattern program
- On
- By
- 0 Comment
- Categories: pyramid triangle, 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
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
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