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.
# 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()
Enter the total Number of Rows: 4
Exponentially Increasing Stars Pattern
*
* *
* * * *
* * * * * * * *
* * * * * * * * * * * * * * * *
# 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()
Enter the total Number of Rows: 3
Exponentially Increasing Stars Pattern
*
* *
* * * *
* * * * * * * *
Comments