ICode国际青少年编程竞赛- Python-2级训练场-for循环中的变量
1、
for i in range(4):
Dev.turnLeft()
# 将i+1作为Dev移动的步数
Dev.step(i + 1)
2、
for i in range(4):
Spaceship.step(i + 1)
Dev.step(3)
Dev.step(-3)
3、
for i in range(5):
Dev.step(5 - i)
Dev.turnRight()
4、
for i in range(3):
Dev.step(i + 2)
Dev.turnRight()
Dev.step(i + 2)
Dev.turnLeft()
5、
for i in range(4):
Flyer[i].step(i + 1)
Dev.step(Dev.y - Item.y)
6、
for i in range(3):
Dev.step(4 - i)
Dev.turnRight()
Dev.step(i + 2)
Dev.turnLeft()
7、
Spaceship.step()
for i in range(4):
Spaceship.step(4 - i)
Spaceship.turnRight()
Spaceship.step(i + 1)
Spaceship.turnLeft()
8、
for i in range(4):
Dev.step(i - 4)
Dev.step(4 - i)
Dev.turnRight()
Spaceship.step(i + 2)
Spaceship.turnRight()
9、
for i in range(4):
Flyer[i].step(i + 1)
Dev.turnLeft()
Dev.step(1)
Dev.turnRight()
Dev.step(2)
10、
Dev.turnLeft()
Dev.step(1)
for i in range(3):
Spaceship.step(i + 1)
Dev.step(i + 1)
Dev.step(-i - 1)
11、
for i in range(6):
Dev.step(i + i + 1)
Dev.turnRight()
12、
for i in range(5):
Dev.turnLeft()
Dev.step(13 - i * 3)
13、
for i in range(3):
Dev.turnRight()
Dev.step(i * 2 + 1)
Dev.turnLeft()
Dev.step(i * 2 + 1)
14、
for i in range(4):
Spaceship.step(2)
Dev.step(2 * i + 1)
Dev.step(-1 - 2 * i)
15、
for i in range(4):
Dev.step(i + 3)
Dev.step(-i - 3)
Dev.turnRight()
16、
for i in range(5):
Spaceship.step(2)
Spaceship.turnLeft()
Spaceship.step(6 - i) # 上
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(8)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(2 + i)
Spaceship.turnRight()
17、
for i in range(4):
Dev.step(i + (i + 1) * 2)
Dev.step(-(i + (i + 1) * 2))
Spaceship.step(2)
18、
for i in range(4):
Flyer[i].step(2 * i + 1)
Dev.step(2)
Dev.turnLeft()
Dev.step(2)
Dev.turnRight()
Dev.step(1)
19、
for i in range(4):
Spaceship.step(i + 1)
Dev.step(7 - i * 2)
Dev.step(i * 2 - 7)
20、
Dev.turnRight()
for i in range(5):
Spaceship.step(2)
Dev.step(8 - i * 2)
Dev.step(-2 * (8 - i * 2))
Dev.step(8 - i * 2)