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

2024-05-14 20:36

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

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

1、

在这里插入图片描述

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

2、
在这里插入图片描述

def go(a, b, c):Flyer[a].step(b)Dev.step(4)Dev.step(-4)Spaceship.step(c)
go(3, 2, 3)
go(4, 1, 2)
go(1, 4, 4)
go(0, 5, 3)
Flyer[2].step(2)
Dev.step(4)

3、
在这里插入图片描述

def go(a, b, c, d):Spaceship.step(a)Flyer[b].step(c)Dev.step(d)Dev.step(-d)
go(1,3,2,4)
go(2,4,1,5)
go(2,6,2,3)
Spaceship.turnRight()
Spaceship.step()
Spaceship.turnLeft()
go(2,1,3,5)
go(3,0,2,8)
go(2,5,3,4)
go(3,7,2,3)
go(1,2,3,5)

4、

在这里插入图片描述

def move(a, b, c):Dev.turnLeft()while Flyer[a].disappear(): wait()Dev.step(b)for i in range(4):Dev.step(2)Dev.turnRight()while Flyer[a].disappear(): wait()Dev.step(-b)Dev.turnRight()Dev.step(c)
move(2, 2, 6)
move(0, 4, 4)
move(1, 3, 4)
move(3, 5, 0)

5、

在这里插入图片描述

def move(a, b, c):Dev.step(a)while Flyer[b].disappear(): wait()Dev.step(6-a)Dev.step(a-4)while Flyer[b].disappear(): wait()Dev.step(-a-2)Spaceship.step(c)move(3, 2, 4)
move(1, 0, 2)
move(4, 4, 3)
move(3, 3, 4)
move(2, 1, 0)

6、

在这里插入图片描述

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

7、

在这里插入图片描述

def move(d1, d2, s1, s2):for i in range(2):Dev.step(d1-i*d2)Dev.turnLeft()Spaceship.step(s1)Dev.step(d1)Spaceship.step(s2)
move(4,2,2,2)
move(-2,-1,1,2)
Spaceship.step(5)
Spaceship.turnRight()
Spaceship.step(2)
Dev.turnRight()
move(5,2,3,2)
move(-3,-2,0,0)

8、
在这里插入图片描述

def move(a, b, c, d):Dev.step(a)Dev.turnRight()Flyer[c].step(d)Dev.step(b)Dev.turnLeft()
move(2,4,0,1)
move(2,3,1,2)
move(4,2,2,1)
move(2,5,3,2)
Dev.step()

9、

在这里插入图片描述

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

10、

在这里插入图片描述

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

11、

在这里插入图片描述

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

12、
在这里插入图片描述

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

13、

在这里插入图片描述

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

14、
在这里插入图片描述

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

15、
在这里插入图片描述

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

16、

在这里插入图片描述

def move(a, b, c, d, e):Spaceship.step(2)Flyer[a].step(b)Dev.step(c)Dev.turnLeft()Dev.step(d)Dev.turnLeft()Spaceship.step(d)Dev.step(c)Spaceship.step(e)Spaceship.turnRight()Dev.turnLeft()
move(1, 4, 4, 3, 8)
move(3, 3, 6, 5, 6)
move(2, 2, 3, 6, 5)
move(0, 2, 1, 9, 1)

17、

在这里插入图片描述

def move(a, b, c, d, ob):for i in range(a):while Flyer[b + i].disappear() == d: wait()ob.step(c)for i in range(2):ob.turnRight()ob.step(c)ob.turnLeft()ob.step(c)move(3, 0, 2, True, Dev)
move(2, 3, 4, False, Spaceship)
Dev.turnLeft()
move(3, 5, 3, True, Dev)

18、
在这里插入图片描述

def move_F(a, b, c, d, e):for i in range(a):Flyer[i * c + b].step(i * d + e)
def move(a, b):Dev.step(a)Dev.turnRight()Dev.step(b)Dev.turnLeft()
move_F(3, 0, 1, 1, 1)
move_F(5, 3, 2, 1, 2)
move(5, 3)
move_F(3, 12, 1, 2, 1)
move(9, 7)
move_F(3, 10, -2, 0, 7)
move_F(2, 3, -2, 3, 3)
move(-6, -4)
Dev.step(-7)

19、

在这里插入图片描述

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

20、
在这里插入图片描述

def move(a, b, c, d, o):Dev.step(a)Dev.turnLeft()if o: for i in range(d): Flyer[i+c].step(i+1)if o != 1: for i in range(d): Flyer[c-i].step(i+1)for i in range(4):Dev.step(b)Dev.turnRight()Dev.step(b)Dev.turnRight()Dev.step(-a)Dev.turnRight()
move(7, 2, 9, 2, 1)
move(4, 3, 8, 4, 0)
move(5, 1, 0, 2, 1)
move(3, 2, 4, 3, 0)

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



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

相关文章

Python函数作用域示例详解

《Python函数作用域示例详解》本文介绍了Python中的LEGB作用域规则,详细解析了变量查找的四个层级,通过具体代码示例,展示了各层级的变量访问规则和特性,对python函数作用域相关知识感兴趣... 目录一、LEGB 规则二、作用域实例2.1 局部作用域(Local)2.2 闭包作用域(Enclos

Python实现对阿里云OSS对象存储的操作详解

《Python实现对阿里云OSS对象存储的操作详解》这篇文章主要为大家详细介绍了Python实现对阿里云OSS对象存储的操作相关知识,包括连接,上传,下载,列举等功能,感兴趣的小伙伴可以了解下... 目录一、直接使用代码二、详细使用1. 环境准备2. 初始化配置3. bucket配置创建4. 文件上传到os

Java内存分配与JVM参数详解(推荐)

《Java内存分配与JVM参数详解(推荐)》本文详解JVM内存结构与参数调整,涵盖堆分代、元空间、GC选择及优化策略,帮助开发者提升性能、避免内存泄漏,本文给大家介绍Java内存分配与JVM参数详解,... 目录引言JVM内存结构JVM参数概述堆内存分配年轻代与老年代调整堆内存大小调整年轻代与老年代比例元空

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互

Python中注释使用方法举例详解

《Python中注释使用方法举例详解》在Python编程语言中注释是必不可少的一部分,它有助于提高代码的可读性和维护性,:本文主要介绍Python中注释使用方法的相关资料,需要的朋友可以参考下... 目录一、前言二、什么是注释?示例:三、单行注释语法:以 China编程# 开头,后面的内容为注释内容示例:示例:四

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

Python中re模块结合正则表达式的实际应用案例

《Python中re模块结合正则表达式的实际应用案例》Python中的re模块是用于处理正则表达式的强大工具,正则表达式是一种用来匹配字符串的模式,它可以在文本中搜索和匹配特定的字符串模式,这篇文章主... 目录前言re模块常用函数一、查看文本中是否包含 A 或 B 字符串二、替换多个关键词为统一格式三、提

MySQL count()聚合函数详解

《MySQLcount()聚合函数详解》MySQL中的COUNT()函数,它是SQL中最常用的聚合函数之一,用于计算表中符合特定条件的行数,本文给大家介绍MySQLcount()聚合函数,感兴趣的朋... 目录核心功能语法形式重要特性与行为如何选择使用哪种形式?总结深入剖析一下 mysql 中的 COUNT

python常用的正则表达式及作用

《python常用的正则表达式及作用》正则表达式是处理字符串的强大工具,Python通过re模块提供正则表达式支持,本文给大家介绍python常用的正则表达式及作用详解,感兴趣的朋友跟随小编一起看看吧... 目录python常用正则表达式及作用基本匹配模式常用正则表达式示例常用量词边界匹配分组和捕获常用re

Go语言数据库编程GORM 的基本使用详解

《Go语言数据库编程GORM的基本使用详解》GORM是Go语言流行的ORM框架,封装database/sql,支持自动迁移、关联、事务等,提供CRUD、条件查询、钩子函数、日志等功能,简化数据库操作... 目录一、安装与初始化1. 安装 GORM 及数据库驱动2. 建立数据库连接二、定义模型结构体三、自动迁