小工具知识网

当前位置: 首页 > 行业知识 > ICode国际青少年编程竞赛- Python-1级训练场-基础训练2

行业知识

ICode国际青少年编程竞赛- Python-1级训练场-基础训练2

2026-11-05 14:58:26 来源:互联网转载

ICode国际青少年编程竞赛- Python-1级训练场-基础训练2

1、

a = 4 #  变量a存储的数字是4Dev.step(a) #  因为变量a的值是4,所以Dev.step(a)就相当于Dev.step(4)

2、

a = 1 #  变量a的值为1for i in range(4):    Dev.step(a)    Dev.turnLeft()    a = a + 1 #  变量a的值变为了2

3、

a = 1for i in range(8):    Dev.step(a)    Dev.turnRight()    a = a + 1

4、

Dev.step(1)a = 1for i in range(3):    Spaceship.step(a)    Dev.step(a)    Dev.step(-a)    a = a + 1

5、

for i in range(5):    Dev.step(i * 2 + 1)  # 1 3 5 7 9    Dev.turnRight()

6、

Spaceship.step(1)for i in range(4):    #  用a和b来控制Spaceship移动的距离    Spaceship.step(4 - i)  # 4 3 2 1    Spaceship.turnRight()    Spaceship.step(i + 1)  # 1 2 3 4     Spaceship.turnLeft()

7、

for i in range(3):    Dev.turnRight()    Dev.step(i + 1)    Dev.turnLeft()    Dev.step(-2 * (i + 1))  

8、

Dev.turnLeft()a = 8for i in range(4):    Spaceship.step(2)    Dev.step(a)    Dev.step(-2 * a)    Dev.step(a)    a = a - 2Spaceship.step(2)

9、

for i in range(4):    Dev.step(i + 1)    Dev.turnLeft()    Dev.step(i + 3)    Dev.step(-(i + 3) * 2)    Dev.step(i + 3)    Dev.turnRight()

10、

dir = 1x = 1for i in range(5):    Dev.step(2)    Dev.turnRight()    Dev.step(dir * x)    Dev.step(-x * dir)    Dev.turnLeft()    dir = -dir    x += 1

11、

Flyer[0].step(1) #  Flyer[0]表示Flyer列表中的第0号元素Flyer[1].step(1) #  Flyer[1]表示Flyer列表中的第1号元素Flyer[2].step()Dev.step(4)

12、

Flyer[0].step(1)Flyer[1].step(2)Dev.step(4)Dev.turnLeft()Dev.step(1)

13、

Flyer[1].step(5)Flyer[2].step(3)Dev.step(6)

14、

Flyer[3].step(1)Flyer[2].step(1)Flyer[0].step(1)Flyer[1].step(1)Dev.step(5)

15、

for i in range(4):    Flyer[i].step(1)for i in range(2):    Dev.step(3)    Dev.turnLeft()for i in range(2):    Flyer[i].step(3)Dev.step(3)

16、

for i in range(3) :    Flyer[i].step(2)Dev.step(6)

17、

for i in range(3):    Flyer[i].step(2)    Dev.step(4)    Dev.turnRight()

18、

for i in range(8) :    Flyer[i].step(2)Dev.step(2)Dev.turnRight()for i in range(3):    Dev.step(5)    Dev.turnLeft()Dev.step(-1)

19、

for i in range(4):    Flyer[i].step(i + 1)Dev.step(8)

20、

for i in range(4):    Flyer[i].step(i + 1)    Dev.step(8)    Dev.turnRight()

上一篇:HTML5+CSS3模拟实现《亮剑》平安县城一役精彩微信群聊-谁开的炮?

下一篇:冰湖钓鱼怎么开服务器?