Python ninety-nine multiplication table for loop

for i in range (1 (10):
for x in range (1)
print ("% DX% d =% 2d"% (i, x, itemx), end ="")
print (")
what sequence is printed on the first line 1 2 3 4 5 6 7 8 9
? I can"t understand it all the time. Is it true that
(1Magne2) (1Magne3) (1Magne4) (1ZHERO5) (1BE6) (1BEI 7) (1BEI 8) (1BEI 9) (1MIRE10)
is that so?

Mar.31,2021

when the for loop is added to the for loop, the running process is simply that every time the outer for loop runs, the inner loop will all cycle once, and the three-layer for cycle and the four-layer for cycle are all this kind of running process, but the number of layers becomes more. Just look at it from the innermost layer

.
 

this is a two-layer loop, which you can understand to mean that each time the outer loop is carried out, the internal loop will carry out a complete cycle.
if you don't understand, you can throw the code into the environment and run:

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

from this run result, think of the entire multiplication table as the first for result, I think you should be able to see the iteration from 1 to 9, and then each line is the result of the second internal for . Here the for x in range (1 is used, so it can be from 1 to I on each layer, which is in line with the ninety-nine multiplication table.
I hope my explanation can make you understand.

Menu