ICode国际青少年编程竞赛- Python-1级训练场-变量练习

ICode国际青少年编程竞赛- Python-1级训练场-变量练习

1、

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

2、

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

3、

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

4、

python 复制代码
a = 1
for i in range(3):
    Spaceship.step(2)
    Spaceship.turnRight()
    Spaceship.step(a)
    Spaceship.turnLeft()
    a *= 3

5、

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

6、

python 复制代码
a = 6
for i in range(4):
    Dev.step(a)
    Dev.turnRight()
    Dev.step(2)
    Dev.turnRight()
    Dev.step(a)
    Dev.turnLeft()
    a -= 1

7、

python 复制代码
a = 8   # 4 2 1
for i in range(4):
    Dev.step(a)
    Dev.turnRight()
    a /= 2
for i in range(3):
    Dev.step(-2)
    Dev.turnLeft()

8、

python 复制代码
a = 6  # 5 4 3
for i in range(3):
    Dev.step(a)
    Dev.turnRight()
    a -= 1
for i in range(3):
    Spaceship.step(a + 1)
    Spaceship.turnLeft()
    a -= 1

9、

python 复制代码
a = 2
b = 4
for i in range(4):
    Dev.step(a)
    Dev.turnRight()
    Dev.step(b)
    Dev.step(-b)
    Dev.turnLeft()
    Dev.step(-a)
    Dev.turnLeft()
    a += 2
    b -= 1

10、

python 复制代码
Spaceship.step()
for i in range(4):
    Spaceship.step(4 - i)
    Spaceship.turnRight()
    Spaceship.step(1 + i)
    Spaceship.turnLeft()

11、

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

12、

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

13、

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

14、

python 复制代码
for i in range(7):
    Dev.step(i + 1)
    Dev.turnRight()
Dev.step(7)
Dev.turnRight()
Dev.step(1)
for i in range(4):
    Spaceship.step(6 - i)
    Spaceship.turnLeft()

15、

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

16、

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

17、

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

18、

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

19、

python 复制代码
a = 2
for i in range(5):
    Dev.step(-a)
    Dev.step(8 + i)
    Dev.step(-6 + i)
    Dev.turnRight()
    Dev.step(2)
    Dev.turnLeft()
    a += 2

20、

python 复制代码
a = 7
b = 3
for i in range(4):
    Dev.step(2)
    Dev.turnRight()
    Dev.step(a)
    Dev.step(-a)
    Dev.turnLeft()
    a = a - b
    b -= 1
相关推荐
zhousenshan5 分钟前
Python爬虫常用框架
开发语言·爬虫·python
IMER SIMPLE26 分钟前
人工智能-python-深度学习-经典神经网络AlexNet
人工智能·python·深度学习
CodeCraft Studio43 分钟前
国产化Word处理组件Spire.DOC教程:使用 Python 将 Markdown 转换为 HTML 的详细教程
python·html·word·markdown·国产化·spire.doc·文档格式转换
专注API从业者1 小时前
Python/Java 代码示例:手把手教程调用 1688 API 获取商品详情实时数据
java·linux·数据库·python
java1234_小锋1 小时前
[免费]基于Python的协同过滤电影推荐系统(Django+Vue+sqlite+爬虫)【论文+源码+SQL脚本】
python·django·电影推荐系统·协同过滤
看海天一色听风起雨落2 小时前
Python学习之装饰器
开发语言·python·学习
XiaoMu_0013 小时前
基于Python+Streamlit的旅游数据分析与预测系统:从数据可视化到机器学习预测的完整实现
python·信息可视化·旅游
THMAIL3 小时前
深度学习从入门到精通 - 生成对抗网络(GAN)实战:创造逼真图像的魔法艺术
人工智能·python·深度学习·神经网络·机器学习·生成对抗网络·cnn
我没想到原来他们都是一堆坏人4 小时前
(未完待续...)如何编写一个用于构建python web项目镜像的dockerfile文件
java·前端·python
总有刁民想爱朕ha5 小时前
车牌模拟生成器:Python3.8+Opencv代码实现与商业应用前景(C#、python 开发包SDK)
开发语言·python·数据挖掘