"""
2.使用循环结构输出如下所示的图形。
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
---------------------
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
"""
# 用来画上半个空心菱形
for i in range(7):
for j in range(6 - i):
print(" ", end="")
for k in range(i):
if k == 0 or k == i - 1:
print("*", end=" ")
else:
print(end=" ")
print()
# 用来画下半个空心菱形
for i in range(5, 0, -1):
for j in range(6 - i):
print(" ", end="")
for k in range(i):
if k == 0 or k == i - 1:
print("*", end=" ")
else:
print(end=" ")
print()
print("-" * 21)
# 用来画三角形
for i in range(10):
for j in range(10 - i):
print(" ", end="")
for k in range(i):
print(" *", end="")
print()