用*号输出不同的三角形

时间:2021-10-01 04:06:16
 
#直角三角形
y = 1
for x in range(4, -1, -1):
    print(" " * x, end = "")
    print("*" * y)
    y += 1
'''
for x in range(1,7):
    for z in range(1, 7-x):
        print(" ", end = "")
    for y in rnage(1, x):
        print("*",end = "")
    print()
'''

#等腰三角形
y = 1
for x in range(3, -1, -1):
    print(" " * x, end = "")
    print("*" * y)
    y += 2

''' 
for x in range(1,5):
    for y in range(1, 5 - x):
        print(" ", end ="")
    for z in range(1, 2*x):
        print("*",end = "")
    print()
'''