1、打印等边三角形
for i in range(0,5): for y in range(0,5-i): w = ‘ ‘ print(w,end="") s = ‘* ‘ * i print(s)
打印结果:
* * * * * * * * * *
2、打印直角三角形
for i in range(10): print(‘*‘*i)
打印结果:
*
**
***
****
for i in range(0,5): for y in range(5-i): w = ‘ ‘ print(w,end=‘‘) print(‘*‘* i)
打印结果:
*
**
***
****