九九乘法表
#!/usr/bin/env python # coding: utf-8 # In[23]: for i in range (1,10): for j in range(1,i+1): print('{}x{}={:<2} '.format(i,j,j*i),end='') print() # In[76]: for i in range (1,10): s = ' ' for j in range(1,i+1): if(i*j<10 and j>1): s = s+'{1} x {0} = {2} '.format(i,j,i*j) else: s = s+'{1} x {0} = {2} '.format(i,j,i*j) #print('{}x{}={:<2} '.format(i,j,j*i),end='') #print('{:>120}'.format(s)) print(s) # In[55]: for i in range (1,10): s = ' ' for j in range(i,10): if(i*j<10): s = s+'{} x {} = {} '.format(i,j,i*j) else: s = s+'{} x {} = {} '.format(i,j,i*j) #print('{}x{}={:<2} '.format(i,j,j*i),end='') print('{:>120}'.format(s)) print()