-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
here you will how to print diamond shape using python
- Loading branch information
0 parents
commit 68c534b
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"" | ||
Write a program to print diamond | ||
|
||
some imple steps to follow: | ||
step1: first the input from user value n i.e how many lines of diamond you want | ||
step2:then use three for loops where | ||
i.first you print space n-i times | ||
ii.second for loop will print * upto (2*i)-1 times | ||
iii.then again print * n-i times | ||
Similarily print inverted triangle | ||
|
||
""" | ||
n=int(input("Enter size of diamond:")) | ||
|
||
|
||
for i in range(1,n): | ||
|
||
for j in range(0,n-i): | ||
|
||
print(" ",end=' ') | ||
|
||
for j in range(0,(2*i)-1): | ||
|
||
print("*",end=' ') | ||
|
||
for j in range(0,n-i): | ||
print(" ",end=' ') | ||
|
||
print() | ||
|
||
for i in range(n,-1,-1): | ||
|
||
for j in range(0,n-i): | ||
|
||
print(" ",end=' ') | ||
|
||
for j in range(0,(2*i)-1): | ||
|
||
print("*",end=' ') | ||
|
||
for j in range(0,n-i): | ||
|
||
print(" ",end=' ') | ||
|
||
print() | ||
|
||
|