ICode国际青少年编程竞赛- Python-5级训练场-函数练习2

2024-05-14 18:52

本文主要是介绍ICode国际青少年编程竞赛- Python-5级训练场-函数练习2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ICode国际青少年编程竞赛- Python-5级训练场-函数练习2

1、
在这里插入图片描述

def get_item(a):Spaceship.step(1)Dev.step(a)Dev.turnLeft()Dev.step(1)Spaceship.step(1)Dev.turnRight()Dev.step(-a)Spaceship.step(1)
get_item(3)
get_item(2)
get_item(3)
get_item(1)
get_item(5)

2、
在这里插入图片描述

def get_item(a):Dev.step(1)for i in range(4):Dev.step(a)Dev.turnRight()Dev.step(-1)Dev.step(1)
get_item(2)
Spaceship.step(5)
get_item(4)
Spaceship.step(6)
get_item(3)
Spaceship.step(6)
get_item(1)

3、

在这里插入图片描述

def get_item(a):Dev.step(1)Flyer[a].step(1)for i in range(4):Dev.step(2)Dev.turnLeft()Dev.step(-1)
get_item(1)
for i in range(2): Dev.turnRight()
Spaceship.step(2)
get_item(2)
Spaceship.step(2)
Spaceship.turnRight()
Spaceship.step(2)
for i in range(2): Dev.turnRight()
get_item(0)

4、

在这里插入图片描述

def move(ok,a):Dev.step(1*ok)for i in range(4):Dev.step(a*ok)if ok == 1: Dev.turnRight()if ok == -1: Dev.turnLeft()Dev.step(-1*ok)
move(1, 2)
Spaceship.step()
Spaceship.turnRight()
Spaceship.step(2)
move(-1, 4)
Spaceship.turnLeft()
Spaceship.step(4)
move(1, 1)
Spaceship.step(3)
Spaceship.turnRight()
Spaceship.step()
move(-1, 3)
for i in range(2):Spaceship.turnLeft()Spaceship.step(2-i)
move(1, 5)

5、
在这里插入图片描述

def move(a, b, c):Spaceship.step(a)Dev.step(2)for i in range(2):Dev.step(b)Dev.turnLeft()Dev.step(c)Dev.turnLeft()Dev.step(-2)
Dev.turnRight()
move(0, 2, 2)
move(4, 4, 2)
move(5, 7, 2)

6、
在这里插入图片描述

def move(a):Dev.step(a)Dev.turnRight()Dev.step(a-1)Dev.turnLeft()Spaceship.step(a-1)Dev.step(-a)
move(3)
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnLeft()
Spaceship.step(2)
move(5)
Spaceship.step(2)
Spaceship.turnLeft()
Spaceship.step(2)
Spaceship.turnRight()
move(4)
Spaceship.turnRight()
Spaceship.step(2)
Spaceship.turnLeft()
Spaceship.step(2)
move(3)

7、

在这里插入图片描述

def get_items(a,b):Dev.step(a)Dev.turnRight()Dev.step(b)Dev.turnLeft()Spaceship.step(b)Dev.step(-a)
get_items(4,2)
Spaceship.step(2)
Spaceship.turnLeft()
Spaceship.step(2)
Spaceship.turnRight()
get_items(3,4)
Spaceship.turnRight()
Spaceship.step(4)
Spaceship.turnLeft()
Spaceship.step(2)
get_items(6,3)
Spaceship.step(2)
Spaceship.turnLeft()
Spaceship.step(3)
Spaceship.turnRight()
get_items(4,1)

8、
在这里插入图片描述

def move(a, b, c):Spaceship.step(a)Dev.step(b)Dev.turnRight()Dev.step(c)Dev.turnLeft()Spaceship.step(c)Dev.step(-b)
Dev.turnLeft()
move(1, 5, 3)
move(2, 4, 1)
move(2, 6, 2)
move(2, 2, 1)
move(2, 3, 2)

9、
在这里插入图片描述

def move(a, b, c):Spaceship.step(a)Dev.step(2)for i in range(2):Dev.step(b)Dev.turnRight()Dev.step(c)Dev.turnRight()Dev.step(-2)
move(0, 3, 2)
move(4, 6, 3)
move(6, 5, 2)
move(4, 2, 3)

10、

在这里插入图片描述

Dev.turnLeft()
def move(a, b, c):Spaceship.step(a)Dev.step(2)for i in range(2):Dev.step(b)Dev.turnRight()Dev.step(c)Dev.turnRight()Dev.step(-2)
move(1, 2, 2)
move(4, 4, 1)
move(3, 6, 4)
move(6, 1, 1)

11、
在这里插入图片描述

def move(a):for i in range(4):Flyer[a+i].step()Dev.step()for i in range(4):Dev.step(4)Dev.turnRight()Dev.step(-1)
move(4)
for i in range(2):Spaceship.turnRight()Spaceship.step(4-i)
Dev.turnRight()
move(8)
Spaceship.step()
Spaceship.turnRight()
Spaceship.step(5)
for i in range(2): Dev.turnRight()
move(0)

12、

在这里插入图片描述

def move(a, b, c, d):if a == 5: Spaceship.turnRight()Spaceship.step(a)if a == 2: Spaceship.turnRight()if a != 2: Spaceship.turnLeft()Spaceship.step(b)Dev.step(-1)for i in range(2):Dev.step(c)Dev.turnRight()Dev.step(d)Dev.turnRight()Dev.step(1)
move(2, 1, -2, -2)
move(4, 6, -1, -1)
move(5, 3, -3, -2)

13、
在这里插入图片描述

def move(a, b, c):Dev.step(a)for i in range(2):Dev.step(b)Dev.turnRight()Dev.step(c)Dev.turnRight()Dev.step(-a)
Dev.turnLeft()
move(1, 3, 3)
Spaceship.step(4)
move(-1, -5, -4)
Spaceship.step(1)
Dev.turnRight()
move(1, 3, 6)
Spaceship.turnLeft()
Spaceship.step(1)
Dev.turnLeft()
move(1, 2, 4)

14、

在这里插入图片描述

def move(a, b):Flyer[a].step(b)Dev.step(3)Spaceship.step(2)for i in range(2):Dev.turnRight()Dev.step(2 + i)move(0, 3)
Dev.turnLeft()
Spaceship.turnRight()
Spaceship.step()
move(2, 4)
Dev.turnLeft()
Spaceship.step(1)
Spaceship.turnRight()
move(1, 1)

15、

在这里插入图片描述

def move(a, b):for i in range(a):Dev.step(b)Dev.turnLeft()Dev.step(-b)if i == 1 and b == 3: Dev.step(-1)if i == 3 and b == 1: Dev.step(-2)Dev.turnRight()
move(2, 2)
Dev.step(3)
move(2, 3)
Dev.step(2)
Dev.turnRight()
Dev.step(1)
move(4, 1)
Dev.step(-2)
Dev.turnRight()
Dev.step()
move(4, 2)

16、
在这里插入图片描述

def move(a, b, c):Spaceship.step(a)Dev.step(c)for i in range(4):Dev.step(b)Dev.turnRight()Dev.step(-c)
move(0, 3, 5)
move(6, 2, 3)
move(4, 4, 3)
move(6, 2, 6)

17、

在这里插入图片描述

def move(a, b, c, d):for i in range(4):Flyer[a+i].step(d)Dev.step(c)for i in range(4):Dev.step(b)Dev.turnRight()Dev.step(-c)
move(0, 4, 1, 1)
Spaceship.turnRight()
Spaceship.step()
Spaceship.turnLeft()
Spaceship.step(8)
move(4, -4, -1, 2)
Spaceship.turnLeft()
Spaceship.step(2)
move(8, 4, 1, 3)

18、

在这里插入图片描述

def move(a, b, c, d):Spaceship.step(a)Dev.step(b)Dev.step(c)Dev.turnLeft()Dev.step(-2)Dev.turnRight()Spaceship.step(2)Dev.step(d)
move(0, 5, -2, -3)
move(2, 3, -1, -2)
move(4, 6, -4, -2)
move(3, 5, -1, -4)

19、

在这里插入图片描述

def f(a,b,c, d):Spaceship.step(d)Dev.step(a)Dev.turnLeft()for i in range(2):Dev.step(b)Dev.turnRight()Dev.step(c)Dev.turnRight()Dev.step(b)Dev.turnRight()Dev.step(-a)
f(5, 1, 2, 0)
f(7, 2, 3, 5)
f(6, 1, 3, 5)
f(10, 2, 3, 4)

20、
在这里插入图片描述

def move(a, b, c, d):Dev.step(b)for i in range(4):Flyer[a+i].step(d)for i in range(4):Dev.step(c)Dev.turnRight()Dev.step(-b)
move(0, 1, 6, 2)
for i in range(2):Spaceship.step(3)Spaceship.turnRight()
move(8, -1, -4, 1)
for i in (1, 3): Spaceship.turnRight()Spaceship.step(i)
Dev.turnRight()
move(4, 1, 2, 1)

这篇关于ICode国际青少年编程竞赛- Python-5级训练场-函数练习2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/989571

相关文章

Python+FFmpeg实现视频自动化处理的完整指南

《Python+FFmpeg实现视频自动化处理的完整指南》本文总结了一套在Python中使用subprocess.run调用FFmpeg进行视频自动化处理的解决方案,涵盖了跨平台硬件加速、中间素材处理... 目录一、 跨平台硬件加速:统一接口设计1. 核心映射逻辑2. python 实现代码二、 中间素材处

python中的flask_sqlalchemy的使用及示例详解

《python中的flask_sqlalchemy的使用及示例详解》文章主要介绍了在使用SQLAlchemy创建模型实例时,通过元类动态创建实例的方式,并说明了如何在实例化时执行__init__方法,... 目录@orm.reconstructorSQLAlchemy的回滚关联其他模型数据库基本操作将数据添

Python实现快速扫描目标主机的开放端口和服务

《Python实现快速扫描目标主机的开放端口和服务》这篇文章主要为大家详细介绍了如何使用Python编写一个功能强大的端口扫描器脚本,实现快速扫描目标主机的开放端口和服务,感兴趣的小伙伴可以了解下... 目录功能介绍场景应用1. 网络安全审计2. 系统管理维护3. 网络故障排查4. 合规性检查报错处理1.

Python轻松实现Word到Markdown的转换

《Python轻松实现Word到Markdown的转换》在文档管理、内容发布等场景中,将Word转换为Markdown格式是常见需求,本文将介绍如何使用FreeSpire.DocforPython实现... 目录一、工具简介二、核心转换实现1. 基础单文件转换2. 批量转换Word文件三、工具特性分析优点局

Python中4大日志记录库比较的终极PK

《Python中4大日志记录库比较的终极PK》日志记录框架是一种工具,可帮助您标准化应用程序中的日志记录过程,:本文主要介绍Python中4大日志记录库比较的相关资料,文中通过代码介绍的非常详细,... 目录一、logging库1、优点2、缺点二、LogAid库三、Loguru库四、Structlogphp

C++,C#,Rust,Go,Java,Python,JavaScript的性能对比全面讲解

《C++,C#,Rust,Go,Java,Python,JavaScript的性能对比全面讲解》:本文主要介绍C++,C#,Rust,Go,Java,Python,JavaScript性能对比全面... 目录编程语言性能对比、核心优势与最佳使用场景性能对比表格C++C#RustGoJavapythonjav

Python海象运算符:=的具体实现

《Python海象运算符:=的具体实现》海象运算符又称​​赋值表达式,Python3.8后可用,其核心设计是在表达式内部完成变量赋值并返回该值,从而简化代码逻辑,下面就来详细的介绍一下如何使用,感兴趣... 目录简介​​条件判断优化循环控制简化​推导式高效计算​正则匹配与数据提取​性能对比简介海象运算符

python项目环境切换的几种实现方式

《python项目环境切换的几种实现方式》本文主要介绍了python项目环境切换的几种实现方式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 如何在不同python项目中,安装不同的依赖2. 如何切换到不同项目的工作空间3.创建项目

python项目打包成docker容器镜像的两种方法实现

《python项目打包成docker容器镜像的两种方法实现》本文介绍两种将Python项目打包为Docker镜像的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要... 目录简单版:(一次成功,后续下载对应的软件依赖)第一步:肯定是构建dockerfile,如下:第二步

Python + Streamlit项目部署方案超详细教程(非Docker版)

《Python+Streamlit项目部署方案超详细教程(非Docker版)》Streamlit是一款强大的Python框架,专为机器学习及数据可视化打造,:本文主要介绍Python+St... 目录一、针对 Alibaba Cloud linux/Centos 系统的完整部署方案1. 服务器基础配置(阿里