python九九乘法表的实例

python2.7

for i in range(1,10):
 for j in range(1,i+1):
  print j,'x',i,'=',j*i,'\t',
 print '\n'
print '\nDone'

python九九乘法表的实例

python3.7

i = 1

while i<=9:
 j = 1
 while j<=i:
  print ("%d*%d=%-2d "%(j,i,j*i),end="")
  j+=1
 print("")
 i+=1

python九九乘法表的实例

相关推荐