python循环嵌套——九九乘法表
程序员文章站
2023-08-18 09:47:39
#用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
上一篇: 设计师牛比啊