Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Python Program for Rhombus Star Pattern
May 29, 2020
Printing Rhombus Star Pattern
In this Python Program, we will be discussing about how to write a program to print Rhombus Star Pattern. A rhombus is a quadrilateral whose four sides all have the same length. So, In this pattern, numbers of rows and equal number of columns are present. So, User have to enter a single value, that will be determine as a number of rows and columns of the pattern.
Working:
Step 1. Start
Step 2. Take number of rows as input from the user and stored it into num.
Step 3. Run a for loop starting from 0 to user entered num value.
Step 4. Inside for loop, Run two for loops where one for printing space and one for printing star for pattern.
Step 5. Move to the next line by printing a new line using print() function.
Stop 6. Stop
Python Program:
num = int(input("Enter the number:"))
for i in range(0, num):
for j in range(1, i+1):
print(" ", end="")
for j in range(0, num):
print("*", end="")
print()
# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
for i in range(rows):
for j in range(i+1):
print(” “, end=” “)
for j in range(i):
print(“*”, end=” “)
for j in range(i, rows):
print(“*”, end=” “)
print()
for i in range(0, num):
for j in range(i+1):
print(” “, end=””)
for j in range(i,num-1):
print(“*”, end=””)
for j in range (i+1):
print(“*”,end=””)
print()
rows = int(input(“Enter the number of rows: “))
for i in range(rows):
for j in range(i+1):
print(” “, end=” “)
for j in range(i):
print(“*”, end=” “)
for j in range(i, rows):
print(“*”, end=” “)
print()
# in python
n=int(input())
for i in range(n):
for j in range(n+i):
if(j<i):
print(' ',end='')
else:
print('*',end='')
print()
n=int(input())
for i in range(n):
print(” “*i,end=””)
for j in range(n):
print(“*”,end=””)
print()
num = int(input(“Enter the number:”))
for i in range(0, num):
for j in range(i+1):
print(” “, end=””)
for j in range(i,num-1):
print(“*”, end=””)
for j in range (i+1):
print(“*”,end=””)
print()
n= int(input(“Enter number: “))
for i in range(n):
print(” “*i,end=””)
for j in range(n):
print(“*”,end=””)
print()
n = int(input())
s = n * ‘*’
for i in range(n):
print(i*’ ‘+s)
num=int(input(“enter”))
for i in range(num):
print(” “* i, “*”*num)
num=int(input())
for i in range(num):
print(” “* i, “* * * *”)
n=int(input())
for i in range(n):
for j in range(i):
print(” “,end=””)
for k in range(n):
print(“*”,end=””)
print()
num=5
for i in range(a):
print(” “*i+’*’*num)
n=int(input())
for i in range(n):
print(i*’ ‘+’*’*n)
a = int(input())
for i in range(a):
print(‘ ‘*i + ‘*’*a)