空心/实心三角形、四边形
打印的方法大同小异,可参考:https://www.cnblogs.com/Python-T/p/9382976.html
for a in range(1,7): for b in range(1,a): print(" ",end="") c=7-a for m in range(1,2*c): if a==1: print("*",end="") elif m==1 or m==2*c-1: print("*",end="") else: print(" ",end="") print()
for i in range(1,7): for j in range(1,7-i): print(" ",end="") for k in range(1,2*i+1-1): print("*",end="") print()
for i in range(1,7): for j in range(1,i): print(" ",end="") for k in range(1,2*(7-i)): print("*",end="") print()
for i in range(1,7): for j in range(0,i): print("*",end="") print()
for i in range(1,7): for j in range(1,7-i): print(" ",end="") for k in range(0,i): print("*",end="") print()
for i in range(1,7): for j in range(1,7-i): print("*",end="") print()
for i in range(1,7): for j in range(1,i): print(" ",end="") for k in range(1,7-i): print("*",end="") print()
for i in range(1,7): print("*",end="") for k in range(1,i): if k==i-1 or i==6: print("*",end="") else: print(" ",end="") print()
for i in range(1,7): for j in range(1,7-i): print(" ",end="") for k in range(0,i): if k==0 or k==i-1: print("*",end="") elif i==6: print("*",end="") else: print(" ",end="") print()
for i in range(1,8): print("*",end="") for j in range(1,8-i): if j==7-i or i==1: print("*",end="") else: print(" ",end="") print()
for i in range(1,7): for j in range(1,i): print(" ",end="") for j in range(1,7-i): if j==1 or j==6-i: print("*",end="") elif i==1: print("*",end="") else: print(" ",end="") print()
for i in range(1,7): for j in range(1,7-i): print(" ",end="") for k in range(1,7): if k==1 or k==6: print("*",end="") elif i==1 or i==6: print("*",end="") else: print(" ",end="") print()
for i in range(1,7): for j in range(1,i): print(" ",end="") for k in range(1,7): if k==1 or k==6: print("*",end="") elif i==1 or i==6: print("*",end="") else: print(" ",end="") print()
for i in range(1,7): for j in range(1,7): if j==1 or j==6: print("*",end="") elif i==1 or i==6: print("*",end="") else: print(" ",end="") print()
for i in range(1,6): for j in range(1,16-i): print(" ",end="") for k in range(1,2*i): if k==1 or k==2*i-1: print("*",end="") else: print(" ",end="") print()
本文来自博客园,作者:Iving,转载请注明原文链接:https://www.cnblogs.com/SAS-T/p/9383503.html