Write a Python program to print pyramid pattern

 TASK:

Write a Python program to print pyramid pattern:

STEPS TO BE TAKEN:

  • It Demands 2 loops One for printing and other for number row
  • We have taken number of row as 5
  • Number of row can also be asked from user

CODE:

#number of rows are taken as 5 
for i in range(5): #this loop will be used to iterate inner loop 5 times

#All information is here:

#in each row number of starts is depending on the value of i
#in keeping this thing in mind we will iterate the following loop for j <=i
   
            for j in range(int(i)+1):
                print("*",end=" ")#printing of starts
            print("\n")#to change line after each iteration


NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post