python应用-打印各种形状图

   

row = int(input('请输入行数: '))
for row in range(1,row):
    for col in range (1,row+1):
        print( (col),end='')
    print()

for i in range(row):
    for _ in range(i + 1):
        print('*', end='')
    print()

for row in range(1,6):
    for col in range(65,65+row):
        print(chr(col),end='')
    print()

for row in range(0,6):
    for col in range(0,row):
        print(chr(row+64),end='')
    print()

for i in range(row):
    for j in range(row):
        if j < row - i - 1:
            print(' ', end='')
        else:
            print('*', end='')
    print()

for i in range(row):
    for _ in range(row - i - 1):
        print(' ', end='')
    for _ in range(2 * i + 1):
        print('*', end='')
    print()  
结果:
请输入行数: 5
1
12
123
1234
*
**
***
****
A
AB
ABC
ABCD
ABCDE

A
BB
CCC
DDDD
EEEEE
    *
   **
  ***
 ****
*****
    *
   ***
  *****
 *******
********* 

  

posted @ 2018-03-11 22:24  圆柱模板  阅读(2254)  评论(0编辑  收藏  举报