python之使用while循环输出如下星图形

简介: python之使用while循环输出如下星图形

代码如下所示:

Row=1
while Row<=5: #控制输出上半部分
    print("* " * Row)
    Row+=1
Row=5
i=4
while Row>=1:  #控制输出下半部分
    print("* " * i)
    Row-=1
    i-=1

输出结果如下所示:

* 
* * 
* * * 
* * * * 
* * * * * 
* * * * 
* * * 
* * 
* 
相关文章
|
Python
python之for、while循环
python之for、while循环
148 0
|
大数据 Python
Python中while循环的嵌套应用详解
Python中while循环的嵌套应用详解
541 0
Python中的while循环
Python中的while循环
|
存储 Python
Python while循环语句
Python while循环语句
651 0
Python While 循环语句
Python While 循环语句
|
Python
Python while 循环
Python while 循环
1218 0
最新【Python】 实现循环最快的方式_python while循环加速,2024年最新阿里php面试题
最新【Python】 实现循环最快的方式_python while循环加速,2024年最新阿里php面试题
2024年最新【Python】循环结构:while 循环(1),阿里巴巴面试常见问题及回答技巧
2024年最新【Python】循环结构:while 循环(1),阿里巴巴面试常见问题及回答技巧
2024年最新【Python】循环结构:while 循环(1),阿里巴巴面试常见问题及回答技巧
【Python操作基础】——while语句用法和pass语句
【Python操作基础】——while语句用法和pass语句
|
Python
Python中的while循环,知其然知其所以然
Python中的while循环,知其然知其所以然
428 2

推荐镜像

更多