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

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

1、

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

2、

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

3、

python 复制代码
a = 1
for i in range(8):
    Dev.step(a)
    Dev.turnRight()
    a = a + 1

4、

python 复制代码
Dev.step(1)
a = 1
for i in range(3):
    Spaceship.step(a)
    Dev.step(a)
    Dev.step(-a)
    a = a + 1

5、

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

6、

python 复制代码
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、

python 复制代码
for i in range(3):
    Dev.turnRight()
    Dev.step(i + 1)
    Dev.turnLeft()
    Dev.step(-2 * (i + 1))  

8、

python 复制代码
Dev.turnLeft()
a = 8
for i in range(4):
    Spaceship.step(2)
    Dev.step(a)
    Dev.step(-2 * a)
    Dev.step(a)
    a = a - 2
Spaceship.step(2)

9、

python 复制代码
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、

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

11、

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

12、

python 复制代码
Flyer[0].step(1)
Flyer[1].step(2)
Dev.step(4)
Dev.turnLeft()
Dev.step(1)

13、

python 复制代码
Flyer[1].step(5)
Flyer[2].step(3)
Dev.step(6)

14、

python 复制代码
Flyer[3].step(1)
Flyer[2].step(1)
Flyer[0].step(1)
Flyer[1].step(1)
Dev.step(5)

15、

python 复制代码
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、

python 复制代码
for i in range(3) :
    Flyer[i].step(2)
Dev.step(6)

17、

python 复制代码
for i in range(3):
    Flyer[i].step(2)
    Dev.step(4)
    Dev.turnRight()

18、

python 复制代码
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、

python 复制代码
for i in range(4):
    Flyer[i].step(i + 1)
Dev.step(8)

20、

python 复制代码
for i in range(4):
    Flyer[i].step(i + 1)
    Dev.step(8)
    Dev.turnRight()
相关推荐
wu_jing_sheng039 分钟前
Python中使用HTTP 206状态码实现大文件下载的完整指南
开发语言·前端·python
程序员大雄学编程1 小时前
「用Python来学微积分」2. 函数图像的变换
python·数学·微积分
Q26433650232 小时前
【有源码】基于Python与Spark的火锅店数据可视化分析系统-基于机器学习的火锅店综合竞争力评估与可视化分析-基于用户画像聚类的火锅店市场细分与可视化研究
大数据·hadoop·python·机器学习·数据分析·spark·毕业设计
unicrom_深圳市由你创科技2 小时前
工业上位机,用Python+Qt还是C#+WPF?
python·qt·c#
njsgcs2 小时前
json转excel python pd
python·json·excel·pd
一晌小贪欢2 小时前
Python爬虫第7课:多线程与异步爬虫技术
开发语言·爬虫·python·网络爬虫·python爬虫·python3
yanxing.D4 小时前
OpenCV轻松入门_面向python(第六章 阈值处理)
人工智能·python·opencv·计算机视觉
JJJJ_iii6 小时前
【机器学习01】监督学习、无监督学习、线性回归、代价函数
人工智能·笔记·python·学习·机器学习·jupyter·线性回归
Python图像识别8 小时前
71_基于深度学习的布料瑕疵检测识别系统(yolo11、yolov8、yolov5+UI界面+Python项目源码+模型+标注好的数据集)
python·深度学习·yolo
千码君20169 小时前
React Native:从react的解构看编程众多语言中的解构
java·javascript·python·react native·react.js·解包·解构