Instagram
youtube
Facebook
Twitter

Python Program to Print Right Half Diamond Pattern

    A Python Program to Print Right Half Diamond Pattern

    
    Short Description:
    
This Python program prints a right half diamond pattern using asterisks (*).
    It first creates an increasing pattern of stars (upper half), then a decreasing pattern (lower half), forming a          diamond shape sliced vertically.


Explanation (in dot points):

  • rows = int(input(...))
    • Takes the number of rows from the user.

     
  • for i in range(1, rows + 1)
    • Prints the upper half of the diamond by increasing the number of stars.

     
  • for i in range(rows - 1, 0, -1)
    • Prints the lower half of the diamond by decreasing the number of stars.

     
  • print("*" * i)
    • Displays i asterisks in each row without spaces.

Program:

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

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

    print("*" * i)

for i in range(rows - 1, 0, -1):

    print("*" * i)