Python-九九乘法表
# -*- coding:utf-8 -*-
# for i in range(1, 2): # 最笨方法
# print('%d X %d = %d' % (i, 1, i * 1),end=' ')
# print(' ')
# for i in range(1, 3):
# print('%d X %d = %d' % (i, 2, i * 2),end=' ')
# print(' ')
# for i in range(1, 4):
# print('%d X %d = %d' % (i, 3, i * 3),end=' ')
# print(' ')
# for i in range(1, 5):
# print('%d X %d = %d' % (i, 4, i * 4),end=' ')
# print(' ')
# for i in range(1, 6):
# print('%d X %d = %d' % (i, 5, i * 5),end=' ')
# print(' ')
# for i in range(1, 7):
# print('%d X %d = %d' % (i, 6, i * 6),end=' ')
# print(' ')
# for i in range(1, 8):
# print('%d X %d = %d' % (i, 7, i * 7),end=' ')
# print(' ')
# for i in range(1, 9):
# print('%d X %d = %d' % (i, 8, i * 8),end=' ')
# print(' ')
# for i in range(1, 10):
# print('%d X %d = %d' % (i, 9, i * 9),end=' ')
a = 1 # 九九乘法表写法一
while a < 10:
a += 1
for i in range(1, a):
print('%d X %d = %d' % (i, (a - 1), i * (a - 1)), end=' ')
print(' ')
for i in range(1,10): # # 九九乘法表写法二
for j in range(1,i+1):
print('%d X %d = %d' % (j,i,j*i),end=' ')
print('')
本文为我原创
本文禁止转载或摘编
--
--
--
分享到:
投诉或建议
评论