PHP前端开发

python中while循环打印星星的四种形状

百变鹏仔 1个月前 (01-23) #Python
文章标签 四种

在控制台连续输出五行*,每一行星号数量一次递增【推荐阅读:python视频教程】
*
**
***
****
*****

#1.定义一个行计数器row = 1while row <p><img src="https://img.php.cn/upload/image/275/957/588/1548141630489447.png" title="1548141630489447.png" alt="20190117145604733.png"></p><pre class="brush:php;toolbar:false">#1.定义一个行计数器row = 1while row = row:        print('*',end='')        col -= 1    print('')    row += 1

那么如果想让空格先,然后*呢

row = 1while row <p><img src="https://img.php.cn/upload/image/232/604/780/1548141743729155.png" title="1548141743729155.png" alt="3.png"></p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/00968c3c2c15"   style="max-width:90%" rel="nofollow" target="_blank">Python免费学习笔记(深入)</a>”;</p><p>另外一种排列方式</p><pre class="brush:php;toolbar:false">row = 1while row <p><img src="https://img.php.cn/upload/image/112/629/108/1548141754510313.png" title="1548141754510313.png" alt="4.png"></p>