用Python编程输出以下图形 (1) * ** *** **** ***** **** *** ** * (2)
时间: 2023-11-26 07:03:32 浏览: 64
python 图形编程
5星 · 资源好评率100%
以下是Python编程输出图形的答案:
(1)
```python
num = 5 # 行数
for i in range(1, num*2):
if i <= num:
print("*" * i)
else:
print("*" * (num*2 - i))
```
(2)
```python
num = 5 # 行数
for i in range(1, num*2):
if i <= num:
print(" " * (num-i) + "*" * i)
else:
print(" " * (i-num) + "*" * (num*2 - i))
```
阅读全文