for i in [10,20,30,40]:
print(i)
for i in range(5):
print(f"square of {i} is {i**2}")
i = 0
while i<5:
print(f"square of {i} is {i**2}")
i += 1
前两个输出都是
square of 0 is 0
square of 1 is 1
square of 2 is 4
square of 3 is 9
square of 4 is 16
some_array = []
for i in range(5):
some_array.append(i**3)
输出:[0, 1, 8, 27, 64]