;

Python Program to Print the Exponentially Increasing Star Pattern


Tutorialsrack 16/05/2020 Python

In this python program, we will learn how to print the exponentially increasing star pattern.

Here is the source code of the program to print the exponentially increasing star pattern.

Program 1: Python Program to Print the Exponentially Increasing Star Pattern Using While Loop

Python Program to Print the Exponentially Increasing Star Pattern Using While Loop
# Python Program to Print the Exponentially
# Increasing Star Pattern Using While Loop

# Import Module
import math

# Take the Input From the User 
rows = int(input("Enter the total Number of Rows: "))

# Print the Output
print("Exponentially Increasing Stars Pattern") 
i = 0
while(i <= rows):
    j = 1
    while(j <= math.pow(2, i)):        
        print('*', end = '  ')
        j = j + 1
    i = i + 1
    print()
Output

Enter the total Number of Rows: 4

Exponentially Increasing Stars Pattern

*  

*  *  

*  *  *  *  

*  *  *  *  *  *  *  *  

*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  

Program 2: Python Program to Print the Exponentially Increasing Star Pattern Using For Loop

Python Program to Print the Exponentially Increasing Star Pattern Using For Loop
# Python Program to Print the Exponentially
# Increasing Star Pattern Using For Loop

# Import Module
import math

# Take the Input From the User 
rows = int(input("Enter the total Number of Rows: "))

# Print the Output
print("Exponentially Increasing Stars Pattern")

for i in range(rows + 1):
    for j in range(1, int(math.pow(2, i) + 1)):        
        print('*', end = '  ')
    print()
Output

Enter the total Number of Rows: 3

Exponentially Increasing Stars Pattern

*  

*  *  

*  *  *  *  

*  *  *  *  *  *  *  * 


Related Posts



Comments

Recent Posts
Tags