Python program to print pyramid pattern of *|python for loop pattern|Python program to print asterisks pyramid|How to print asterisk patter in python|write a program to print the following pattern in python

Introduction

In this python program, we will learn how to print the following pattern using FOR loop

We can print asterisk " * " in the same manner as shown following:


Pattern:-         *
                     **
                     ***
                     ****
                     *****


For Loop

for loop is used for iteration over a sequence (for example. a list, a tuple, a string or a dictionary).
But in this Code we have used it for incrementing numbers.To do so we have used the range() function.

The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a number specified specified by the user.

User can specify the Starting,end and the incrementation difference.


To know how to print Number pyramid pattern using python:-https://learntechpython.blogspot.com/2021/05/python-program-to-print-pattern-of.html


We Are Going to cover:-
  • how to print patterns in python using for loop
  • how to print star Pyramid patterns in python using for Loop.

It is also known as asterisk pyramid pattern.


Following is the full code and output:-
Source Code(Using "For " loop):-
n=int(input("enter number of rows needed:"))

for i in range(1,n+1):

    for j in range(1, i+1):

        print("*", end="")
    print()

#Code ends


Screenshot:-


Output:-



"HOPE IT HELPED"

Have anything in mind? Let me 
know in the comment section👇
Next Post Previous Post
No Comment
Add Comment
comment url