用*号输出不同的三角形

 
  
#直角三角形
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()
'''   
        


你可能感兴趣的:(用*号输出不同的三角形)