python打印乘法表

Posted 一个tester的独白

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python打印乘法表相关的知识,希望对你有一定的参考价值。

要点在于,end=""表示下个print不换行

实例:

1 for x in range (1,10):
2      for y in range(1,10):
3          if x>=y:
4             print(x,"x",y,"=",x*y,"  ",end="")
5      print()

输出结果

1 x 1 = 1   
2 x 1 = 2   2 x 2 = 4   
3 x 1 = 3   3 x 2 = 6   3 x 3 = 9   
4 x 1 = 4   4 x 2 = 8   4 x 3 = 12   4 x 4 = 16   
5 x 1 = 5   5 x 2 = 10   5 x 3 = 15   5 x 4 = 20   5 x 5 = 25   
6 x 1 = 6   6 x 2 = 12   6 x 3 = 18   6 x 4 = 24   6 x 5 = 30   6 x 6 = 36   
7 x 1 = 7   7 x 2 = 14   7 x 3 = 21   7 x 4 = 28   7 x 5 = 35   7 x 6 = 42   7 x 7 = 49   
8 x 1 = 8   8 x 2 = 16   8 x 3 = 24   8 x 4 = 32   8 x 5 = 40   8 x 6 = 48   8 x 7 = 56   8 x 8 = 64   
9 x 1 = 9   9 x 2 = 18   9 x 3 = 27   9 x 4 = 36   9 x 5 = 45   9 x 6 = 54   9 x 7 = 63   9 x 8 = 72   9 x 9 = 81   

 

以上是关于python打印乘法表的主要内容,如果未能解决你的问题,请参考以下文章

使用VS2017进行Python代码的编写并打印出九九乘法表

python怎么打印99乘法表

怎么用python打印出乘法表?

python打印九九乘法表?

Python实现不同格式打印九九乘法表

Python实现不同格式打印九九乘法表