Python Program to Print a Rhombus Pattern
Beginner · Patterns
In pattern programs, a rhombus is a slanted square: every row has the same number of stars, and each row starts one space further left than the row above, so the shape leans. Some books also use the name for the diamond pattern. This program prints a solid rhombus of 5 rows with 5 stars each.
Program
***** ***** ***** ***** *****
How it works
- Each row starts with
rows - ispaces: 4 on the first row, then 3, 2, 1 and none. - After the spaces, every row prints the same
rowsstars, which is what makes it a rhombus rather than a triangle. - The starting point moves one place left on each row while the length stays the same, so the two sides come out slanted and parallel.
- The empty
print()ends each row so the next one starts on a new line.
Other ways to write it
Hollow rhombus
***** * * * * * * *****
The first and last rows are full, and every other row has a star at each end with rows - 2 spaces between them, so only the outline is drawn.
Rhombus leaning the other way
*****
*****
*****
*****
*****Starting with no spaces and adding one per row makes the rhombus lean to the right instead.
Try it yourself
Give each row 8 stars while keeping 5 rows, which turns the rhombus into a parallelogram.
Edit the program above and press Run, or open it in the full editor to save it and share it. To watch it run line by line, open it in the visualizer.
Related programs
All Python programs · CBSE class 12 practical file · Python exercises