Python 算法集合

1.请用python语言编写一个乘法口诀

第一种方法

for firstNumb in range(1,10):
for twonumber in range(1,firstNumb+1):
print("%d*%d=%d"%(firstNumb,twonumber,firstNumb*twonumber),end='')
print('')
第二种方法:
row=1
while row<9:
r=1
while r<=row:
# print(str(row)+"*"+str(r)+"="+str(row*r),end='')也可以或者
print("%d*%d=%d"%(row,r,row+r),end='')
r+=1
print("")
row+=1
posted @ 2018-12-19 11:26  小朋友写代码  阅读(133)  评论(0编辑  收藏  举报