Created
December 30, 2022 06:59
-
-
Save Xaypanya/791c1c5f987b126683d900c3fe7c199f to your computer and use it in GitHub Desktop.
heart pattern in python
This file contains hidden or 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
n = 8 | |
m = n+1 | |
for i in range(n//2-1): | |
for j in range(m): | |
if i == n//2-2 and (j == 0 or j == m-1): | |
print("*", end=" ") | |
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=" ") | |
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=" ") | |
else: | |
print(" ", end=" ") | |
print() | |
for i in range(n//2-1, n): | |
for j in range(m): | |
if (i-j == n//2-1) or (i+j == n-1+m//2): | |
print('*', end=" ") | |
elif i == n//2-1: | |
if j == m//2: | |
print('F', end=" ") | |
else: | |
print(' ', end=" ") | |
else: | |
print(' ', end=" ") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment