1.打印直角三角形
#*
#* *
#* * *
#* * * *
#* * * * *
for n in range(5):
for m in range(n + 1):
print("*", end=" ")
print()
2.打印反直角三角形
# *
# * *
# * * *
# * * * *
# * * * * *
for i in range(5):
for n in range(5 - i):
print(" ", end=" ")
for j in range(i + 1):
print("*", end=" ")
print()
3.打印等腰三角形
# *
# * *
# * * *
# * * * *
# * * * * *
for i in range(5):
for n in range(5 - i):
print(" ", end=" ")
for j in range(i + 1):
print("* ", end=" ")
print()
4.打印奇葩三角形(一)
# * * * * *
# * * * *
# * * *
# * *
# *
#
# *
# * *
# * * *
# * * * *
# * * * * *
for i in range(5):
for n in range(i + 1):
print(" ", end=" ")
for j in range(5 - i):
print("*", end=" ")
print()
print()
for i in range(5): # 负责行号
for n in range(5 - i):
print(" ", end=" ")
for j in range(i + 1): # 列的数量
print("*", end=" ")
print()
5.打印奇葩三角形(二)
#*
#* *
#* * *
#* * * *
#* * * * *
#* * * * *
#* * * *
#* * *
#* *
#*
for i in range(10):
if i < 5:
for m in range(i + 1):
print("*", end=" ")
print()
else:
for c in range(10 - i):
print("*", end=" ")
print()