1.打印矩形
    2.打印左直角三角形
    3.打印右直角三角形
    4.打印等腰三角形
    5.打印倒三角形

    1. # 矩形
    2. for i in range(0, 3):
    3. for j in range(0, 5):
    4. print("1 ", end='')
    5. print('')
    6. -----------------------------
    7. #1 1 1 1 1
    8. #1 1 1 1 1
    9. #1 1 1 1 1
    1. # 左直角三角形
    2. # 方式一:
    3. for i in range(0, 5):
    4. for j in range(0, i+1):
    5. print('2', end='')
    6. print('')
    7. # 方式二:
    8. for i in range(1, 6):
    9. for j in range(1, i+1):
    10. print('', end='')
    11. print('3'*i)
    12. ---------------------------
    13. #2
    14. #22
    15. #222
    16. #2222
    17. #22222
    18. #3
    19. #33
    20. #333
    21. #3333
    22. #33333
    1. # 右直角三角形
    2. for i in range(1, 6):
    3. for j in range(1, 6-i):
    4. print(' ', end='')
    5. print('4'*i)
    6. -------------------------
    7. # 4
    8. # 44
    9. # 444
    10. # 4444
    11. #44444
    1. # 等腰三角形
    2. # 方式一
    3. for i in range(1, 6):
    4. for j in range(1, 6-i):
    5. print(" ", end="")
    6. print("5 "*i)
    7. # 方式二:
    8. for i in range(1, 6):
    9. for j in range(1, 6-i):
    10. print(' ', end='')
    11. for k in range(1, i+1):
    12. print('6 ', end='')
    13. print('')
    14. ---------------------------------
    15. # 5
    16. # 5 5
    17. # 5 5 5
    18. # 5 5 5 5
    19. #5 5 5 5 5
    20. # 6
    21. # 6 6
    22. # 6 6 6
    23. # 6 6 6 6
    24. #6 6 6 6 6
    1. # 倒三角形
    2. for i in range(0, 5):
    3. for j in range(1, i+1):
    4. print(' ', end='')
    5. for k in range(0, 5-i):
    6. print('7 ', end='')
    7. print('')
    8. -------------------------------
    9. #7 7 7 7 7
    10. # 7 7 7 7
    11. # 7 7 7
    12. # 7 7
    13. # 7