ICode国际青少年编程竞赛- Python-3级训练场-if else语句
1、

for i in range(9):
if Flyer[i].x < Dev.x:
Flyer[i].step(Dev.x - Flyer[i].x)
else:
Flyer[i].step(Flyer[i].x - Dev.x)
Dev.step(Dev.y - Item.y)
2、

for i in range(6):
if Flyer[i].x < Dev.x:
# 满足条件执行Flyer[i].step(1)
Flyer[i].step(1)
else:
#不满足条件执行Flyer[i].step(2)
Flyer[i].step(2)
Dev.step(Dev.y - Item[0].y)
3、

for i in range(5):
if Flyer[i].x > Dev.x:
Flyer[i].step(Flyer[i].x - Dev.x)
else:
Flyer[i].step(Dev.x - Flyer[i].x)
Dev.step(Dev.y - Item[0].y)
4、

for i in range(5):
Dev.step(2)
Dev.turnRight()
if i < 3:
Dev.step(4)
Dev.step(-4)
else:
Dev.step(-2)
Dev.step(2)
Dev.turnLeft()
5、

for i in range(4):
Dev.step(i+1)
Dev.turnLeft()
if i == 2:
Dev.step(-4)
Dev.step(4)
else:
Dev.step(3)
Dev.step(-3)
Dev.turnRight()
6、

for i in range(4):
Dev.step(i + 1)
Dev.turnLeft()
if i != 1:
Dev.step(i+1)
Dev.step(-i-1)
else:
Dev.step(-i-1)
Dev.step(i+1)
Dev.turnRight()
7、

for i in range(5):
Dev.step(2)
Dev.turnLeft()
if i < 3:
Dev.step(i+1)
Dev.step(-i-1)
else:
Dev.step(-4)
Dev.step(4)
Dev.turnRight()
8、

for i in range(6):
Spaceship.step(4)
if i == 2:
Spaceship.turnLeft()
else:
Spaceship.turnRight()
9、

for i in range(8):
Dev.step(i+1)
if i < 4:
Dev.turnLeft()
else:
Dev.turnRight()
10、

for i in range(9):
Dev.step(9-i)
if i < 3:
Dev.turnRight()
else:
Dev.turnLeft()
11、

for i in range(2):
Dev.step(3)
Dev.turnRight()
if i == 0:
Spaceship.step(3)
Dev.step(3)
Dev.step(-3)
Dev.turnLeft()
else:
Dev.step(-2)
12、

for i in range(5):
Spaceship.step(3)
if i == 1:
Spaceship.turnRight()
else:
Spaceship.turnLeft()
13、

for i in range(6):
Dev.step(2)
Dev.turnLeft()
if i != 1:
Dev.step(2)
Dev.step(-2)
else:
Dev.step(-3)
Dev.step(3)
Dev.turnRight()
14、

for i in range(7):
Spaceship.step(Spaceship.y - Item[i].y)
if not Item[i].broken():
if Item[i].x < Dev.x:
Spaceship.turnLeft()
Spaceship.step(2)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnLeft()
else:
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnRight()
15、

for i in range(4):
Spaceship.step(3)
if not Item[2 * i + 1].broken():
Dev.step(4)
Dev.step(-4)
else:
Dev.step(-4)
Dev.step(4)
16、

for i in range(6):
Dev.step(2)
Dev.turnLeft()
if Dev.y > Item[i].y:
Dev.step(3)
Dev.step(-3)
else:
Dev.step(-2)
Dev.step(2)
Dev.turnRight()
17、

Dev.turnLeft()
for i in range(6):
Spaceship.step(2)
if not Item[i*2].broken():
Dev.step(4)
Dev.step(-4)
else:
Dev.step(-4)
Dev.step(4)
18、

for i in range(6):
Spaceship.step()
if i < 2:
Dev.step(-3)
Dev.step(3)
Spaceship.turnLeft()
else:
Spaceship.step(3)
Spaceship.turnRight()
Spaceship.turnRight()
Spaceship.step(3)
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnRight()
19、

for i in range(8):
if i < 3:
Dev.turnLeft()
else:
Dev.turnRight()
Dev.step(i+1)
20、

for i in range(4):
Dev.step(3)
Dev.turnRight()
if i < 2:
Dev.step(2)
Dev.step(-2)
else:
Dev.step(-2)
Dev.step(2)
Dev.turnLeft()
Dev.step(4)
Dev.turnRight()



















