python打印九九乘法表的菱形实现

python打印九九乘法表的菱形实现[Python基础]

 1 NUM = 9

2for i in range(1, NUM+1):

3print()

4for j in range(1, i+1):

5if j == 1:

6print(5*(NUM-i)*(""), end="")

7print("{0} * {1} = {2} ".format(j, i, i*j), end="")

8

9for i in range(NUM-1, 0, -1):

10print()

11for j in range(1, i+1):

12if j == 1:

13print(5*(NUM-i)*(""), end="")

14print("{0} * {1} = {2} ".format(j, i, i*j), end="")

15

16

效果如图:

以上是 python打印九九乘法表的菱形实现 的全部内容, 来源链接: utcz.com/z/537820.html

回到顶部