Created
September 4, 2019 03:07
-
-
Save atul-chaudhary/3e5d5e512f144cd06980d73637e598fe to your computer and use it in GitHub Desktop.
HOTS: pattern program
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
pattern runs for both odd and even number starting from n==3 | |
n==3 | |
* * * * * | |
* * * | |
* * * * | |
* * * * * | |
n==4 | |
* * * * * * | |
* * * | |
* * * * | |
* * * * * | |
* * * * * * | |
n==5 | |
* * * * * * * | |
* * * | |
* * * * | |
* * * * * | |
* * * * * * | |
* * * * * * * | |
#here is the programs | |
n=int(input()) | |
s=n-1 | |
s1=n-1 | |
for _ in range(n+2): | |
print('*',end=' ') | |
print() | |
for i in range(1,n+1): | |
print('*',end=' ') | |
for _ in range(s): | |
print(end=' ') | |
s-=1 | |
for j in range(i): | |
print('*',end=' ') | |
for _ in range(s1): | |
print(end=' ') | |
s1-=1 | |
print('*',end='') | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment