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
相关推荐
橡晟4 小时前
深度学习入门:让神经网络变得“深不可测“⚡(二)
人工智能·python·深度学习·机器学习·计算机视觉
墨尘游子4 小时前
神经网络的层与块
人工智能·python·深度学习·机器学习
倔强青铜34 小时前
苦练Python第18天:Python异常处理锦囊
开发语言·python
企鹅与蟒蛇5 小时前
Ubuntu-25.04 Wayland桌面环境安装Anaconda3之后无法启动anaconda-navigator问题解决
linux·运维·python·ubuntu·anaconda
autobaba5 小时前
编写bat文件自动打开chrome浏览器,并通过selenium抓取浏览器操作chrome
chrome·python·selenium·rpa
Rvelamen6 小时前
LLM-SECURITY-PROMPTS大模型提示词攻击测评基准
人工智能·python·安全
【本人】6 小时前
Django基础(一)———创建与启动
后端·python·django
SHIPKING3938 小时前
【python】基于pygame实现动态粒子爱心
开发语言·python·pygame
kk_stoper9 小时前
如何通过API查询实时能源期货价格
java·开发语言·javascript·数据结构·python·能源
java1234_小锋9 小时前
【NLP舆情分析】基于python微博舆情分析可视化系统(flask+pandas+echarts) 视频教程 - 架构搭建
python·自然语言处理·flask