发布时间:2019-09-27 07:09:02编辑:auto阅读(2256)
99乘法表在第一象限
# #一 for i in range(1,10): for j in range(1,10): if j <= i: print("%s * %s = %-5s"%(j,i ,i*j),end='') print()
第二象限
# #二 # for x in range(1,10): # print(end=' '*(9-x)) # for k in range(1,10): # y=10-k # if y <= x: # print('%s * %s = %-5s'%(y,x,x*y),end='') # print()
第三象限
for i in range(1,10): for k in range(1,i): print(end=" ") for j in range(i,10): print("%d * %d = %2d "%(i,j,i*j),end=' ') print("")
第四象限
#四 for i in range(1,10): x=10-i for j in range(1,10): y=j if y <= x: print("%s * %s = %-5s"%(y,x ,y*x),end='') print()
四合一乘法函数
class chengfa: def __init__(self,num): self.num = int(num) def chorse(self): if self.num == 1: self.chengfa(1,10,1,1,10,1) elif self.num == 2: self.chengfa(9,0,-1,1,10,1) elif self.num == 3: self.chengfa(9,0,-1,9,0,-1) elif self.num == 4: self.chengfa(1,10,1,9,0,-1) else: print('你输入错误!') def chengfa(self,start_num1,end_num1,jian1,start_num2,end_num2,jian2): for i in range(start_num1, end_num1, jian1): for j in range(start_num2, end_num2, jian2): if j <= i: print('%-1s * %-1s = %-2s' % (j, i, i * j), end='| ') else: print(' ' * 12, end='') print() num = input('请输入,你想要查看乘法表的象限: ') test = chengfa(num) test.chorse()
上一篇: linux 安装pip 和python3
下一篇: Python3 字符编码
47750
46252
37132
34640
29231
25893
24762
19866
19426
17916
5720°
6323°
5843°
5892°
6992°
5830°
5850°
6365°
6319°
7683°