ipythondisplaythrets为我学校的python课程编辑

SSSsnake的Python项目详细描述


斯斯纳克

IPythonDisplayTurtle为我们的学校python类添加了功能。在

如何从终端/命令提示符安装:

pip install SSSsnake

从jupyter笔记本单元安装:

^{pr2}$

使用方法:

# Code adapted from one of the exercises made for my schoolfromSSSsnakeimportSSSsnake### VVV this segment can be hidden from students!snake=SSSsnake(homeX=0,homeY=7)defhouseAtXY(x,y):return[[x-1,y,3],[x+1,y,1],[x+2,y,4],[x+2,y+1,0],[x+2,y+2,0],[x+2,y+3,5],[x+1,y+3,1],[x,y+3,1],[x-1,y+3,2],[x-1,y+2,0],[x-1,y+1,0]]walls=[];doors=[];walls.extend(houseAtXY(2,0));doors.append([2,0,1]);walls.extend(houseAtXY(7,1));doors.append([7,1,1]);walls.extend(houseAtXY(12,2));doors.append([12,2,1])snake.drawLevel(xSize=16,ySize=8,gridSize=25,walls=walls,doors=doors)snake.speed(10)snake.pendown()# the snake can do more than you think! It can Draw!# --------------------- vv Work zone vv --------------------- defsmartmove(amount):foriinrange(amount):snake.forward()# TODO: define a function, Hint: you can use the smart move from before here as well!# Also this snake knows how to turn left :)### you would leave the function empty for the students to fill!defdrawncolumn(height):snake.left()smartmove(height)snake.right()snake.forward()snake.right()smartmove(height)snake.left()# TODO: draw 3 collumns of length 3, 2, and 1, under the houses! smartmove(2)drawncolumn(3)smartmove(4)drawncolumn(2)smartmove(4)drawncolumn(1)smartmove(2)# --------------------- ^^ Work zone ^^ ---------------------snake.display()

Example Turtle

Binder

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
hashmap Java如何以列表作为值组织映射   java二进制搜索树如何在“main”中调用我的inoder方法,并在输出中省略null?   java Subclipse如何覆盖更改的文件   java无法识别的VM选项“ExplicitGCInvokesConcurrentAndUnloadsClasses”   java需要从字符串中转义“| |”条件   JavaMVEL迭代列表   如果有对元素字段的引用,java会对元素进行垃圾收集吗?   java如何按索引删除行   java有没有简单的http服务来检查域名的可用性   java Spring@ContextConfiguration无法从不同的项目加载测试上下文   IntelliJ IDEA社区版中的java Webservice客户端   netbeans从java Main调用另一个java文件中的方法   java MySQL左连接和组连接返回重复和中断数据   Java\Hibernate\ManyTone\Ordering   java JPQL中的LIMIT子句是什么?   在Java中,预处理器将单词转换为基本形式   在核心java中创建GUI时的swing问题   java从javabean创建不可变对象   java线程是否可能在wait()循环中饿死?   java有spring用来从xml解析setter数据的助手类吗?