python 金字塔图形

a = 50
y = '*'*(a+1)
p = ' '

while a:
    
    print(y)
    y = y[:a-1]
    y = p  + y
    a = a - 1
   

 

for i in range(20): 
    print(' ' * (20-i-1) + '*' * (2*i+1) )

 

a = 20
p = ' '*(a+1)
s = '*'
b = 1

while a:
    t = p + s*b

    print(t)

    t = t + s*2 
    
    t = t[1:]

    b = b + 2
    p = p[1:]
   
    a = a - 1

 

转载于:https://www.cnblogs.com/wumac/p/5618399.html

你可能感兴趣的:(python 金字塔图形)