num1 = 1 #顺的9*9的乘法表 while num1 <= 9: num2 = 1 while num2 <= num1: print("%d*%d=%d "%(num1,num2,num1*num2),end = "") num2 += 1 print() num1 += 1
row = 9 #倒的9*9的乘法表 while row > 0: col = 1 while col <= row: print(str(row)+"*"+str(col)+"=",row*col, end=" ") col += 1 print() row -= 1