-
Notifications
You must be signed in to change notification settings - Fork 0
/
prac.py
54 lines (42 loc) · 1.47 KB
/
prac.py
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
# define size n = even only
n = 8
# so this heart can be made n//2 part left,
# n//2 part right, and one middle line
# i.e; columns m = n + 1
m = n+1
# loops for upper part
for i in range(n//2-1):
for j in range(m):
# condition for printing stars to GFG upper line
if i == n//2-2 and (j == 0 or j == m-1):
print("*", end=" ")
# condition for printing stars to left upper
elif j <= m//2 and ((i+j == n//2-3 and j <= m//4) \
or (j-i == m//2-n//2+3 and j > m//4)):
print("*", end=" ")
# condition for printing stars to right upper
elif j > m//2 and ((i+j == n//2-3+m//2 and j < 3*m//4) \
or (j-i == m//2-n//2+3+m//2 and j >= 3*m//4)):
print("*", end=" ")
# condition for printing spaces
else:
print(" ", end=" ")
print()
# loops for lower part
for i in range(n//2-1, n):
for j in range(m):
# condition for printing stars
if (i-j == n//2-1) or (i+j == n-1+m//2):
print('*', end=" ")
# condition for printing GFG
elif i == n//2-1:
if j == m//2-1 or j == m//2+1:
print('G', end=" ")
elif j == m//2:
print('F', end=" ")
else:
print(' ', end=" ")
# condition for printing spaces
else:
print(' ', end=" ")
print()