python循环嵌套——九九乘法表
程序员文章站
2022-05-18 08:50:37
#用for 循环for i in range(1,10): #print(i) # print(i*'*') for j in range(1,i+1): print('%d * %d = %d'%(j,i,i*j),end=' ') print('\n')#用while 循环 i = 1while ......
#用for 循环
for i in range(1,10):
#print(i)
# print(i*'*')
for j in range(1,i+1):
print('%d * %d = %d'%(j,i,i*j),end=' ')
print('\n')
#用while 循环
i = 1
while i <= 9:
j = 1
# print(i)
while j <= i:
# print(j)
print('%d * %d = %d ' %(j,i ,i*j),end=' ')
j = j + 1
print('\n')
i = i +1
上一篇: 鲍超:湘军第一猛将,陈玉成都打不过他