需要最终在屏幕显示结果为:
1、
*
**
***
****
*****
代码如下:
"""
# _*_coding:utf-8_*_
Name:xing.py
Date:1/14/19
Author:westos-sql
Connect:[email protected]
Desc:...
"""
row = 1
while row <= 5:
col = 1
while col <= row:
print('*',end='')
col += 1
print('')
row += 1
结果如下:
2、
*****
****
***
**
*
代码如下:
"""
# _*_coding:utf-8_*_
Name:xing.py
Date:1/14/19
Author:westos-sql
Connect:[email protected]
Desc:...
"""
row = 5
while row >= 1:
col = 1
while col <= row:
print('*', end='')
col += 1
row -= 1
print('')
执行结果如下:
3、
*
**
***
****
*****
代码如下:
"""
# _*_coding:utf-8_*_
Name:xing.py
Date:1/14/19
Author:westos-sql
Connect:[email protected]
Desc:...
"""
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
执行结果如下:
4、
*****
****
***
**
*
代码如下:
"""
# _*_coding:utf-8_*_
Name:xing.py
Date:1/14/19
Author:westos-sql
Connect:[email protected]
Desc:...
"""
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
执行结果如下: