- Python Program Examples
- Python Program Examples
- Python Print Hello World
- Python Get Input from User
- Python Add Two Numbers
- Python Check Even or Odd
- Python Check Prime or Not
- Python Check Alphabet or Not
- Python Check Vowel or Not
- Python Check Leap Year or Not
- Python Check Reverse equal Original
- Python Check Positive Negative Zero
- Python Add Subtract Multiply Divide
- Python Make Simple Calculator
- Python Add Digits of Number
- Python Find Sum of Natural Numbers
- Python Calculate Average Percentage
- Python Calculate Average of Numbers
- Python Calculate Grade of Student
- Python Print Multiplication Table
- Python Find Square Root of Number
- Python Print Prime Numbers
- Python Solve Quadratic Equation
- Find Numbers Divisible by Number
- Python Find Factors of Number
- Python Find Reverse of Number
- Python Swap Two Numbers
- Python Swap Two Variables
- Python Find Largest of Two Number
- Python Find Largest of Three Number
- Python Find Factorial of a Number
- Python Find HCF & LCM
- Python Calculate Area of Square
- Python Calculate Area of Rectangle
- Python Calculate Area of Triangle
- Python Calculate Area of Circle
- Python Calculate Perimeter of Square
- Python Find Perimeter of Rectangle
- Python Find Perimeter of Triangle
- Python Find Circumference of Circle
- Python Print ASCII Values
- Python Print Fibonacci Series
- Python Display Powers of 2
- Python Generate Armstrong Numbers
- Python Check Armstrong or Not
- Python Check Palindrome or Not
- Python Find ncR & nPr
- Python Convert Kilometres to Miles
- Python Convert Fahrenheit to Celsius
- Python Convert Celsius to Fahrenheit
- Python Convert Decimal to Binary
- Python Convert Decimal to Octal
- Python Decimal to Hexadecimal
- Python Convert Binary to Decimal
- Python Convert Binary to Octal
- Python Binary to Hexadecimal
- Python Convert Octal to Decimal
- Python Convert Octal to Binary
- Python Convert Octal to Hexadecimal
- Python Hexadecimal to Decimal
- Python Hexadecimal to Binary
- Python Convert Hexadecimal to Octal
- Python Display Calendar
- Python Print Pattern Programs
- Python Print Floyd Triangle
- Python One Dimension Array Program
- Python Add Two Matrices
- Python Subtract Two Matrices
- Python Transpose Matrix
- Python Matrix Multiplication Program
- Python Print String
- Python Find Length of String
- Python Compare Two Strings
- Python Copy String
- Python Concatenate String
- Python Reverse a String
- Python Remove Vowels from String
- Remove Punctuations from String
- Python Remove Words from Sentence
- Python Count Character in String
- Python Count Number of Each Vowels
- Python Count Word in Sentence
- Python Remove Spaces from String
- Python Sort String in Alphabetical
- Python Uppercase to Lowercase
- Python Lowercase to Uppercase
- Python Different Set of Operations
- Python Swap Two Strings
- Python Generate Random Numbers
- Python Read a File
- Python Write to File
- Python Copy Files
- Python Merge Two Files
- Python List Files in Directory
- Python Delete Files
- Python Print Date and Time
- Python Get IP Address
- Python Shutdown & Restart Computer
- Python Tutorial
- Python Tutorial
- Python Test
- Python Online Test
- Give Online Test
- Register Now
- Login Page
- All Test List

To print star pyramid patterns in python, you have to use two or more than two for loops. In program that prints pattern contains two for loops, the first loop is responsible for rows and the second for loop is responsible for columns. Here you will find the code and learn how to print star pattern, star pyramid pattern, number pattern, number pyramid pattern, alphabet pattern, alphabet pyramid pattern, etc.

Here, you will find many code to print different-different patterns in python. All pattern programs given along with their respective output.

Let's start with pattern programming using python to print star, number and alphabet pyramid patterns.

Following python program prints the pyramid pattern of stars:

# Python Program - Pattern Program 1 for i in range(0, 5): for j in range(0, i+1): print("* ",end="") print()

Here is the sample run of the above python program to illustrates how to print pattern using stars:

In first row you will see only 1 star, in second row you will see 2 stars and so on upto
5^{th} row. Printing of star starts from very first column in every row.

Here is the screenshot of python shell where the same program is written and run:

Following python program also prints the pyramid pattern of stars but in different style:

# Python Program - Pattern Program 2 k = 1 for i in range(0, 5): for j in range(0, k): print("* ", end="") k = k + 2 print()

Here is the sample run of the above python program to illustrates the pattern printing of stars:

In first row you will see only 1 star, in second row you will see 1+2, that is 3 star and so
on upto 5^{th} row.

Here is the same program on python shell:

Following python program also prints the pyramid pattern of stars but in third style:

# Python Program - Pattern Program 3 k = 8 for i in range(0, 5): for j in range(0, k): print(end=" ") k = k - 2 for j in range(0, i+1): print("* ", end="") print()

Here is the sample run of the above python pattern program:

In first row you will see 1 star, in second row you will see 2 star and so on, but the printing
of star starts from right side, or from very first column from right side, or very last column
from left side, or from 1^{st} row and 5^{th} column, or from 0^{th} row and
4^{th} column.

Below is the same program directly written and run on python shell:

Here is another python pattern program prints pyramid pattern of stars in fourth style:

# Python Program - Pattern Program 4 k = 16 tim = 1 for i in range(0, 5): for j in range(0, k): print(end=" ") k = k - 4 for j in range(0, tim): print("* ", end="") tim = tim + 2 print()

Here is the sample run of the above Python program:

Printing of star in this program is same as in above one except in first row, you will se 1
star and in second row you will see **1+2** that is 3 star and so on.

Here is same program on python shell:

Following python program prints the pyramid pattern of numbers:

# Python Program - Pattern Program 5 n = 1 for i in range(0, 5): for j in range(0, i+1): print(n, end=" ") n = n + 1 print()

Here is the sample run of the above python program to show how to print the pyramid pattern of numbers:

In first row you will see 1, in second row you will see 2 3, in third row you will see 4 5 6 and so on. Numbers in every row stars from very first column.

Here is same program on python shell:

Following python program prints the pyramid pattern of numbers in second style:

# Python Program - Pattern Program 6 num = 1 for i in range(0, 5): num = 1 for j in range(0, i+1): print(num, end=" ") num = num + 1 print()

Here is the sample run of the above Python program:

In first row you will see 1, in second row you will see 1 2, in third row you will see 1 2 3, and so on.

Following python program print the pattern of stars in another style:

# Python Program - Pattern Program 7 k = 0 rows = 10 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 = k + 1 k = 0 print()

Here is the sample run of the above Python program:

Following python program prints the pyramid pattern of alphabets:

# Python Program - Pattern Program 8 val = 65 for i in range(0, 5): for j in range(0, i+1): ch = chr(val) print(ch, end=" ") val = val + 1 print()

Here is the sample run of the above Python program to illustrates how to print pyramid pattern of alphabets:

Following python program also prints the pyramid pattern of alphabets in different style:

# Python Program - Pattern Program 9 val = 65 for i in range(0, 5): for j in range(0, i+1): ch = chr(val) print(ch, end=" ") val = val + 1 print()

Here is the sample run of the above Python program:

You will see A in first row, B B in second row, C C C in third row and so on.

Below is another python program print pattern of stars:

# Python Program - Pattern Program 10 for i in range(0, 5): for j in range(5, i, -1): print("* ", end="") print()

Here is the sample run of the above Python program:

Here is another python program to print pattern of numbers:

# Python Program - Pattern Program 11 num = 1 for i in range(0, 5): for j in range(5, i, -1): print(num, end=" ") num = num + 1 print() num = 1

Here is the sample run of the above Python program:

This is another version of pattern program in python to print pattern of numbers:

# Python Program - Pattern Program 12 num = 1 incr = 1 for i in range(0, 5): for j in range(0, incr): print(num, end=" ") num = num + 1 print() incr = incr + 2

Here is the sample run of the above Python program:

This is the another version of pattern program in python to print pattern of numbers:

# Python Program - Pattern Program 13 num = 1 count = 0 decr = 8 for i in range(0, 5): for k in range(0, decr): print(end=" ") for j in range(0, i): count = count + 1 num = count temp = num for j in range(0, i): print(num, end=" ") num = num - 1 print() num = temp decr = decr - 2

Here is the sample run of the above Python program:

Below is another version of pattern printing program in python to illustrates how to print pattern of alphabets:

# Python Program - Pattern Program 14 incr = 1 val = 65 for i in range(0, 5): for j in range(0, incr): ch = chr(val) print(ch, end=" ") val = val + 1 incr = incr + 2 print()

Here is the sample run of the above Python program:

Let's see another pattern program in python to print pattern of alphabets:

# Python Program - Pattern Program 15 decr = 8 count = 64 val = 65 for i in range(0, 5): for k in range(0, decr): print(end=" ") for j in range(0, i+1): count = count + 1 val = count temp = val for j in range(0, i+1): ch = chr(val) print(ch, end=" ") val = val - 1 val = temp decr = decr - 2 print()

Here is the sample run of the above Python program:

You may also like to learn or practice the same program in other popular programming languages:

- Java Star Pyramid Pattern Programs
- C Star Pyramid Pattern Programs
- C++ Star Pyramid Pattern Programs