# reference : introduction to programming using python(Y.Daniel Liang)
正方形形状的表现方法(乘法口诀中有重复项)
print(' Multiplication Table')# display the number title
print(' ',end=' ')
for j in range(1,10):
print(' ',j,end='')print()# jump to the new line
print('--------------------------------------------------')
for i in range(1,10):
print(i,'|',end=' ')
for j in range(1,10):
print(format(i*j,"4d"),end=' ')
print()
三角形形状的表现方法
for i in range(1,10):
for j in range(1,10):
if (j<=i):
print(format(i,'2d'),'×',format(j,'2d'),'=',format(i*j,'2d'),' ',end=' ')
print()