DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
threadspeed
threadspeed

Posted on

Drawing with Python turtle?

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:

turtle python

Related links:

Top comments (0)

πŸ‘‹ Hey, my name is Noah and I’m the one who set up this ad. My job is to get you to join DEV, so if you fancy doing me a favor, I’d love for you to create an account.

If you found DEV from searching around, here are a couple of our most popular articles on DEV: