zoukankan      html  css  js  c++  java
  • python基础练习题09

    在控制台连续输出五行*,每一行星号的数量依次递增

    row=1
    while row<=5:
        col=1
        while col<=row:
            print('*',end='')
            col+=1
        print()
        row+=1
    
    # 输出结果
    # *
    # **
    # ***
    # ****
    # *****

    02:

    row=5
    while row>=1:
        col=1
        while col<=row:
            print('*',end='')
            col+=1
        print('')
        row-=1
    
    # 输出结果
    # *****
    # ****
    # ***
    # **
    # *

    03:

    row=1
    while row<=5:
        col=1
        space=1
        while col <=5-row:
            print(' ',end='')
            col+=1
        while space<=row:
            print('*',end='')
            space+=1
        print('')
        row+=1
    # 输出结果:
    #
    #     *
    #    **
    #   ***
    #  ****
    # ***

    04:

    row=5
    while row>=1:
        col=1
        space=1
        while col<=5-row:
            print('',end='')
            col+=1
        while space<=row:
            print('*',end='')
            space+=1
        print('')
        row -= 1
    # 输出结果:
    # *****
    #  ****
    #   ***
    #    **
    #     *
    我是kelly-凯莉 每天努力一点点,幸运就多一点点
  • 相关阅读:
    数据访问类
    批量删除与查询
    CRUD
    数据访问与全局变量
    设计模式
    加载类
    PDO数据访问抽象层(上)
    PDO数据访问抽象层(下)
    会话控制
    php租房题目
  • 原文地址:https://www.cnblogs.com/kelly11/p/12125512.html
Copyright © 2011-2022 走看看