1.单循环打印十行十个小星星使用循环结构 一行的显示结果 **********
代码:
i=0
while i<100:
print("*",end="")
if i%10==9:
print()
i+=1
2.双向循环打印十行十个小星星使用循环结构 一行显示结果 **********
代码:
j=0
while j<10:
i=0
while i<10:
print("*",end="")
i+=1
print()
j+=1
3.用双向循环完成十行十列隔列小表情
#用双向循环完成十行十列隔列小表情
j=0
while j<10:
i=0
while i<10:
if i%2==0:
print("●▽●",end="")
else:
print("●0●",end="")
if i%10==9:
print()
i+=1
j+=1
'''
单循环
i=0
while i<100:
if i%2 == 0:
print("●▽●",end="")
else:
print("●0●",end="")
if i%10==9:
print()
i+=1
'''
实现结果:
4.#用双向循环完成十行十列隔行小表情
#用双向循环完成十行十列隔行小表情
j=0
while j<10:
i=0
if j%2==0:
while i<10:
print("●▽●",end="")
i+=1
else:
while i<10:
print("●0●",end="")
i+=1
print()
j+=1
如果看着冗余一些可以将while循环提出来,变成
while i <10:
if j%2==0:
print("●▽●",end="")
else:
print("●▽●",end="")
i+=1
实现结果:
5.打印九九乘法表
#九九乘法表
j=1
while j<10:
i=1
while i<=j:
print("%d*%d=%d " % (j,i,j*i),end="")
i+=1
print()
j+=1
实现结果: