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

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

 1 NUM = 9
 2 for i in range(1, NUM+1):
 3     print()
 4     for j in range(1, i+1):
 5         if j == 1:
 6             print(5*(NUM-i)*(" "), end="")
 7         print("{0} * {1} = {2} ".format(j, i, i*j), end="")
 8 
 9 for i in range(NUM-1, 0, -1):
10     print()
11     for j in range(1, i+1):
12         if j == 1:
13             print(5*(NUM-i)*(" "), end="")
14         print("{0} * {1} = {2} ".format(j, i, i*j), end="")
15 
16         
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » python打印九九乘法表的菱形实现