python循环语法,9*9乘法表

'''while'''
i = 0
while i < 10:
i += 1
j = 0
while j < 10:
j += 1
print('{}*{}={}'.format(j, i, i * j), end=' ')
if j >= i:
print('\n')
break
'''for方法一'''
for i in range(1,10):
for j in range(1,10):
print('{}*{}={}'.format(j,i,i*j),end=' ')
if j >= i:
print('')
break
'''for方法二'''
for i in range(1,10):
for w in range(1,10):
print(f'{w}*{i}={i*w}',end=' ')
if w >= i:
print('')
break
'''for方法三'''
for i in range(1,10):
for j in range(1,i+1):
print('{}X{}={} '.format(j,i,i*j), end=' ')
print()


posted @ 2019-01-08 00:08  万骨枯  阅读(406)  评论(0编辑  收藏  举报