基础知识练习

九九乘法表

print和for循环知识点

print( x,end = ' ' ) 不换行

print(' ') 换行

for i in range(1,10):
    for j in range(1,i+1):
        print( '%d X %d = %d' % (j,i,i*j),end = '  ' )
    print('  ')
1
2
3
4

打印结果

1 X 1 = 1
1 X 2 = 2  2 X 2 = 4
1 X 3 = 3  2 X 3 = 6  3 X 3 = 9
1 X 4 = 4  2 X 4 = 8  3 X 4 = 12  4 X 4 = 16
1 X 5 = 5  2 X 5 = 10  3 X 5 = 15  4 X 5 = 20  5 X 5 = 25
1 X 6 = 6  2 X 6 = 12  3 X 6 = 18  4 X 6 = 24  5 X 6 = 30  6 X 6 = 36
1 X 7 = 7  2 X 7 = 14  3 X 7 = 21  4 X 7 = 28  5 X 7 = 35  6 X 7 = 42  7 X 7 = 49
1 X 8 = 8  2 X 8 = 16  3 X 8 = 24  4 X 8 = 32  5 X 8 = 40  6 X 8 = 48  7 X 8 = 56  8 X 8 = 64
1 X 9 = 9  2 X 9 = 18  3 X 9 = 27  4 X 9 = 36  5 X 9 = 45  6 X 9 = 54  7 X 9 = 63  8 X 9 = 72  9 X 9 = 81
1
2
3
4
5
6
7
8
9