版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
版权
Python专栏收录该内容
29 篇文章0 订阅
订阅专栏
""" 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()