-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrangoli.py
More file actions
64 lines (47 loc) · 1.29 KB
/
rangoli.py
File metadata and controls
64 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
n=int(input())
character=chr(64+n)
width=n+n-1+n-1+n-1
str_wid=3
for i in range(1,n+1):
if i==1:
print(character.center(width,'-'))
else:
word=""
jj=0
for j in range(0,int(str_wid/2)):
if j==str_wid/2-1:
word=word+chr(64+n-j)+"-"
else:
word=word+chr(64+n-j)+"-"
jj+=1
jj-=2
while jj>=0:
if jj==0:
word=word+chr(64+n-jj)
else:
word=word+chr(64+n-jj)+"-"
jj-=1
print(word.center(width,"-"))
str_wid+=2
str_wid-=4
for i in range(1,n):
if i==n-1:
print(character.center(width,'-'))
else:
word=""
jjj=0
for j in range(0,int(str_wid/2)):
if j==str_wid/2-1:
word=word+chr(64+n-j)+"-"
else:
word=word+chr(64+n-j)+"-"
jjj+=1
jjj-=2
while jjj>=0:
if jjj==0:
word=word+chr(64+n-jjj)
else:
word=word+chr(64+n-jjj)+"-"
jjj-=1
print(word.center(width,"-"))
str_wid-=2