1.while 迴圈 : 2.for 迴圈: ...
1.while 迴圈 :
x = 1 while x < 10: y = 1 while y <=x: print('%d*%d=%2d' % (y,x,x*y),end = '\t') y += 1 x += 1 print('\n')
2.for 迴圈:
for i in range(1,10): for k in range(1,i+1): #排除結果相同的表達式,如1*2和2*1 print('%d*%d=%2d' % (k,i,i*k),end = '\t') print('\n')