while循环方式
【Python输出菱形程序】i=1
while(i<=7):
j = 1
k = 1
if(i<=4):
while(k<=4-i):
print(’ ‘,end=’’)
k+=1
while(j<=i2-1):
print(’’,end=’’)
j+=1
print()
else:
while(k<=3-(7-i)):
print(’ ‘, end=’’)
k += 1
while(j<=(7-i)2+1):
print(’’, end=’’)
j += 1
print()
i+=1
for循环方式
for i in range(1,8):
if(i<=4):
for j in range(1,(5-i)):
print(’ ‘,end =’’)
for k in range(0,(2i-1)):
print(’’,end=’’)
else:
for j in range(0,3-(7-i)):
print(’ ‘,end=’’)
for k in range(0,(7-i)2+1):
print(’’,end=’’)
print()
推荐阅读
- java|Velocity模板引擎实战(动态生成HTML、Word、Excel等报表)
- S1:|在go中玩下gRPC
- Eclipse IDE for Java EE Developers 去哪里了()