while 语句的九九乘法表:

##九九乘法表

#总共有九行
# 每行中的列数,就是当前所处的行号
#乘式的第一个数代表的是列,第二个数代表的是行

row = 1
#行
column = 1
#列
while row <= 9:
while column <= row:
print('%d * %d = %d, '%(column,row,column * row),end='')
column += 1
print('') #换行
row += 1
column = 1

for 语句的九九乘法表:

for row in range (1,10):
for column in range(1,row +1):
print('%d * %d = %d, '%(column,row,column * row,),end="")
column +=1
print(' ')
row += 1
column = 1

 输出结果如下:

 

posted on 2019-06-18 09:43  yaya9098  阅读(406)  评论(0编辑  收藏  举报