Turtle designs is a mainstream path for acquainting Python programming with kids. It was a piece of the first Logo programming language created by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967.
Envision a mechanical turtle beginning at (0, 0) in the x-y plane. After an import turtle:
- provide it the order turtle.forward(15)
- proceeds onward (screen!) 15 pixels toward the path it is confronting, drawing a line as it moves.
- Provide it the order turtle.right(25), and it pivots set up 25 degrees clockwise.
The program below demonstrates the use of Python turtle:
import turtle
turtle.shape("turtle")
turtle.speed(10)
turtle.pendown()
turtle.begin_fill
turtle.color('green')
turtle.circle (100)
turtle.pencolor('red')
turtle.fillcolor('blue')
turtle.end_fill
turtle.pendown()
turtle.circle(100)
turtle.goto(0,200)
turtle.right(90)
turtle.forward (100)
turtle.right (45)
turtle.forward(100)
turtle.left (180)
turtle.forward(200)
turtle.left(180)
turtle.forward(100)
turtle.right (45)
turtle.forward(100)
turtle.backward(200)
turtle.forward(100)
turtle.right(45)
turtle.forward(100)
turtle.backward(200)
turtle.forward(100)
turtle.right(45)
turtle.left(25)
turtle.hideturtle()
The program above draws:
Related links:
Top comments (0)