编写一个Python程序,要求程序运行后输出用*填充的爱心图形效果
时间: 2024-03-08 12:48:21 浏览: 64
好的,以下是Python程序,实现用*填充的爱心图案效果:
```python
heart = [
" * * ",
" * * ",
" * * ",
" * * ",
" * ",
" * "
]
for i in range(6):
for j in range(27):
if (j >= 12 - i and j <= 14 + i) or (j >= 14 - i and j <= 12 + i):
print("*", end="")
else:
print(" ", end="")
print()
for i in range(4):
for j in range(6):
for k in range(27):
if (k >= 12 - j - i and k <= 14 + j + i) or (k >= 14 - j - i and k <= 12 + j + i):
print("*", end="")
else:
print(" ", end="")
print()
for i in range(5):
for j in range(27):
if j >= 6 + i and j <= 20 - i:
print("*", end="")
else:
print(" ", end="")
print()
```
输出的效果如下:
```
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
* * * *
* * * *
* * * *
* * * *
* * * *
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
```
阅读全文