python蟒蛇
1. 封装drawSnake()函数2. 通过多次调节参数并调用drawSnake()函数在一块大画布上画出5条不同颜色、长度、形状的蛇
(实在不会做了........哭死(;´༎ຶД༎ຶ`) )
import turtle def drawSnake(radius, angle, length): turtle.seth(-40) for i in range(length): turtle.circle(radius, angle) turtle.circle(-radius, angle) turtle.circle(radius, angle/2) turtle.fd(40) turtle.circle(16, 180) turtle.fd(40* 2/3) turtle.setup(650, 450, 200, 200) turtle.penup() turtle.fd(-250) turtle.circle(0, 90) turtle.fd(175) turtle.pendown() turtle.pensize(25) turtle.pencolor("yellow") drawSnake(40, 80, 4) turtle.penup() turtle.circle(0, 90) turtle.fd(100) turtle.circle(0, 90) turtle.fd(-450) turtle.pendown() turtle.pencolor("green") drawSnake(40, 80, 4) turtle.penup() turtle.circle(0, 90) turtle.fd(100) turtle.circle(0, 90) turtle.fd(-450) turtle.pendown() turtle.pencolor("red") drawSnake(40, 80, 4) turtle.penup() turtle.circle(0, 90) turtle.fd(100) turtle.circle(0, 90) turtle.fd(-450) turtle.pendown() turtle.pencolor("blue") drawSnake(40, 80, 4) turtle.penup() turtle.circle(0, 90) turtle.fd(100) turtle.circle(0, 90) turtle.fd(-450) turtle.pendown() turtle.pencolor("black") drawSnake(40, 80, 4) turtle.done()
[此贴子已经被作者于2023-3-27 10:18编辑过]