Draw C python
description
"The Python programming language base (2nd Edition)," Section 2.3 gives a "python draw" example, as follows:
#DrawPython.py
import turtle
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
turtle.circle(40, 80)
turtle.circle(-40, 80)
turtle.circle(40, 80/2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2/3)
Outputting the code as follows:
Modify the above code, write a "python Draw" extended instance, requirements:
(1) and the output of the python effect different from the above drawing, the output effect may be different: color, length, angle, attitude and the like.
(2) there is a certain creativity.
(3) using Python turtle library
Entry
No user input.
Export
Python draw, and dynamic display of the drawing process.
other requirements
In the last line of code, increasing turtle.done () as the end.
# Code
import turtle
def drawsnake(rad,angle,len,neckrad):
a = ['blue','red','yellow','green','pink']
for i in range(0,len):
turtle.pencolor(a[i])
turtle.circle(rad,angle)
turtle.circle(-rad,angle)
turtle.pencolor('black')
turtle.circle(rad,angle/2)
turtle.fd(rad)
turtle.circle(neckrad+1,180)
turtle.fd(rad*2/3)
def main():
turtle.setup(1300,800,0,0)
pythonsize = 30
turtle.pensize(pythonsize)
turtle.seth(-40)
drawsnake(40,80,5,pythonsize/2)
turtle.done()
main()