ICode国际青少年编程竞赛- Python-1级训练场-for循环与变量
1、
a = 1
for i in range(4):
Spaceship.step(a)
Dev.step(2)
Dev.step(-2)
a = a + 1
2、
a = 1
for i in range(4):
Spaceship.step(a)
Dev.step(3)
Dev.step(-3)
a = a + 1
3、
a = 1
for i in range(4):
Dev.turnLeft()
Dev.step(a)
a = a + 1
4、
a = 5
for i in range(5):
Dev.step(a)
Dev.turnRight()
a = a - 1
5、
a = 5
for i in range(4):
Spaceship.step(a)
Spaceship.turnLeft()
a = a - 1
6、
a = 6
for i in range(5):
Spaceship.step(a)
Spaceship.turnRight()
a = a - 1
7、
a = 1
for i in range(3):
Dev.step(a)
Dev.turnLeft()
Dev.step(a)
Dev.turnRight()
a = a + 1
8、
a = 2
for i in range(3):
Dev.step(a)
Dev.turnRight()
Dev.step(a)
Dev.turnLeft()
a = a + 1
9、
a = 1
for i in range(6):
Dev.step(a)
Dev.turnRight()
a = a + 2
10、
a = 2
for i in range(3):
Dev.step(a)
Dev.turnRight()
Dev.step(4)
Dev.step(-4)
Dev.turnLeft()
a = a + 2
11、
a = 1
for i in range(3):
Dev.step(a)
Dev.turnRight()
Dev.step(2)
Dev.step(-4)
Dev.step(2)
Dev.turnLeft()
a = a + 1
12、
a = 13
for i in range(5):
Dev.turnLeft()
Dev.step(a)
a = a - 3
13、
a = 3
for i in range(4):
Spaceship.step(a)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(a)
Spaceship.turnRight()
a = a + 1
14、
a = 1
for i in range(3):
Dev.turnRight()
Dev.step(a)
Dev.turnLeft()
Dev.step(a)
a = a + 2
15、
a = 1
for i in range(4):
Dev.step(a)
Dev.turnRight()
a = a * 2
16、
a = 1
for i in range(4):
Dev.step(a)
Dev.turnLeft()
a = a * 2
17、
a = 8
for i in range(4):
Dev.step(a)
Dev.turnRight()
a = a / 2
18、
a = 12
for i in range(3):
Dev.step(a)
Dev.turnRight()
a = a / 2
19、
a = 1
for i in range(3):
Dev.step(2)
Dev.turnLeft()
Dev.step(a)
Dev.turnRight()
a = a * 3
20、
a = 1
for i in range(4):
Spaceship.step(a)
Dev.turnLeft()
Dev.step(-2)
Dev.step(2)
a = a * 2
Spaceship.turnLeft()