1、乘法表
1)左下三角
print('*****Multiplication Table*****')
print('**| 1 2 3 4 5 6 7 8 9')
print('**|---------------------------')
for i in range(1,10):
print(str(i)+' |',end="")
for j in range(1,i+1):
print(format(i*j, '3d'),end="")
print()
?????????????????????????????????
2)右上三角
print('*****Multiplication Table*****')
print('**| 1 2 3 4 5 6 7 8 9')
print('**|---------------------------')
for i in range(1,10):
print(str(i)+' |',end="")
for k in range(1,i):
print(format("***"),end="")
for j in range(i,10):
print(format(i*j, '3d'),end="")
print()
???????????????????????????????????????
2、数字金字塔
print('*****Number Pyramid*********')
for i in range(1,6):
for j in range(5,i,-1):
print(format(" "),end="")
for j in range(i,0,-1):
print(format(j, '3d'),end="")
for j in range(2, i+1):
print(format(j, "3d"),end="")
print()
???????????? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ???????????????????????
?
|