输出九九乘法表。
1 #第一种显示方式 2 row = 1 3 4 while row <= 9: 5 column = 1 6 while column <= row: 7 print(str(column) + "*" + str(row) + "=" + str(column * row), end=" ") 8 column += 1 9 print() 10 row += 1 11 12 print("-" * 100) 13 #第二种显示方式 14 row = 9 15 16 while row > 0: 17 column = 1 18 while column <= row: 19 print(str(column) + "*" + str(row) + "=" + str(column * row), end=" ") 20 column += 1 21 print() 22 row -= 1
运行结果如下: