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

相关文章

Django开发时如何避免频繁发送短信验证码(python图文代码)

《Django开发时如何避免频繁发送短信验证码(python图文代码)》Django开发时,为防止频繁发送验证码,后端需用Redis限制请求频率,结合管道技术提升效率,通过生产者消费者模式解耦业务逻辑... 目录避免频繁发送 验证码1. www.chinasem.cn避免频繁发送 验证码逻辑分析2. 避免频繁

精选20个好玩又实用的的Python实战项目(有图文代码)

《精选20个好玩又实用的的Python实战项目(有图文代码)》文章介绍了20个实用Python项目,涵盖游戏开发、工具应用、图像处理、机器学习等,使用Tkinter、PIL、OpenCV、Kivy等库... 目录① 猜字游戏② 闹钟③ 骰子模拟器④ 二维码⑤ 语言检测⑥ 加密和解密⑦ URL缩短⑧ 音乐播放

python panda库从基础到高级操作分析

《pythonpanda库从基础到高级操作分析》本文介绍了Pandas库的核心功能,包括处理结构化数据的Series和DataFrame数据结构,数据读取、清洗、分组聚合、合并、时间序列分析及大数据... 目录1. Pandas 概述2. 基本操作:数据读取与查看3. 索引操作:精准定位数据4. Group

Python pandas库自学超详细教程

《Pythonpandas库自学超详细教程》文章介绍了Pandas库的基本功能、安装方法及核心操作,涵盖数据导入(CSV/Excel等)、数据结构(Series、DataFrame)、数据清洗、转换... 目录一、什么是Pandas库(1)、Pandas 应用(2)、Pandas 功能(3)、数据结构二、安

Python使用Tenacity一行代码实现自动重试详解

《Python使用Tenacity一行代码实现自动重试详解》tenacity是一个专为Python设计的通用重试库,它的核心理念就是用简单、清晰的方式,为任何可能失败的操作添加重试能力,下面我们就来看... 目录一切始于一个简单的 API 调用Tenacity 入门:一行代码实现优雅重试精细控制:让重试按我

Python安装Pandas库的两种方法

《Python安装Pandas库的两种方法》本文介绍了三种安装PythonPandas库的方法,通过cmd命令行安装并解决版本冲突,手动下载whl文件安装,更换国内镜像源加速下载,最后建议用pipli... 目录方法一:cmd命令行执行pip install pandas方法二:找到pandas下载库,然后

MySQL常用字符串函数示例和场景介绍

《MySQL常用字符串函数示例和场景介绍》MySQL提供了丰富的字符串函数帮助我们高效地对字符串进行处理、转换和分析,本文我将全面且深入地介绍MySQL常用的字符串函数,并结合具体示例和场景,帮你熟练... 目录一、字符串函数概述1.1 字符串函数的作用1.2 字符串函数分类二、字符串长度与统计函数2.1

Python实现网格交易策略的过程

《Python实现网格交易策略的过程》本文讲解Python网格交易策略,利用ccxt获取加密货币数据及backtrader回测,通过设定网格节点,低买高卖获利,适合震荡行情,下面跟我一起看看我们的第一... 网格交易是一种经典的量化交易策略,其核心思想是在价格上下预设多个“网格”,当价格触发特定网格时执行买

Python标准库之数据压缩和存档的应用详解

《Python标准库之数据压缩和存档的应用详解》在数据处理与存储领域,压缩和存档是提升效率的关键技术,Python标准库提供了一套完整的工具链,下面小编就来和大家简单介绍一下吧... 目录一、核心模块架构与设计哲学二、关键模块深度解析1.tarfile:专业级归档工具2.zipfile:跨平台归档首选3.

使用Python构建智能BAT文件生成器的完美解决方案

《使用Python构建智能BAT文件生成器的完美解决方案》这篇文章主要为大家详细介绍了如何使用wxPython构建一个智能的BAT文件生成器,它不仅能够为Python脚本生成启动脚本,还提供了完整的文... 目录引言运行效果图项目背景与需求分析核心需求技术选型核心功能实现1. 数据库设计2. 界面布局设计3