用Python输出各种9x9乘法表(左上,右上,左下,右下)
1 # -*- coding:utf-8 -*-
2 # @Author : 飘飘_emmm
3 # 输出基本乘法表:
4 for i in range(1,10):
5 for j in range(1,10):
6 print(("%d*%d=%2d" % (i,j,i*j),end = " "))
7 print()
8
9 # 输出左上角三角形乘法表:
10 for i in range(1,10):
11 for j in range(i,10):
12 print(("%d*%d=%2d" % (i,j,i*j),end = " "))
13 print()
14
15 # 输出左下角三角形乘法表:
16 for i in range(1,10):
17 for j in range(1,i+1):
18 print(("%d*%d=%2d" % (i,j,i*j),end = " "))
19 print()
20
21 # 输出右上角三角形乘法表:
22 for i in range(1,10):
23 for k in range(1,i):
24 print(end= " ")
25 for j in range(i,10):
26 print(("%d*%d=%2d" % (i,j,i*j),end = " "))
27 print()
28
29 # 输出右下角三角形乘法表:
30 for i in range(1,10):
31 for k in range(1,10-i):
32 print(end= " ")
33 for j in range(1,i+1):
34 print(("%d*%d=%2d" % (i,j,i*j),end = " "))
35 print()