Instagram
youtube
Facebook
Twitter

Python Program to Print Number Half Pyramid Pattern

    A Python Program to Print Number Half Pyramid Pattern
    

    Short Description:
    This program prints a half pyramid made of increasing numbers in each row, starting            from 1.
    It uses nested loops to print the sequence of numbers in a pyramid format.

    Explanation:

  • rows is the number of rows to print.
     
  • Outer loop (i) controls the number of rows.
     
  • Inner loop (j) prints numbers from 1 to i in each row.
     
  • After printing each row, print() moves the cursor to the next line.

Program:

rows = int(input("Enter the number of rows: "))

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

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

        print(j, end=" ")

    print()