TURTLE GRAPHICS IN PYTHON

GOCOURSE


Turtle Graphics

Python's popular turtle graphics feature lets you use a turtle cursor to draw pictures and shapes on the screen in a fun and easy way.

To Execute A Turtle Program You Follow Five Steps:

  • Import the turtle library
  • Create a drawing board(Window)
  • Create a turtle
  • Use turtle methods to perform some operation
  • Run turtle.done().

Example 1: 

To create window and importing turtle

Program:


  import turtle  #import turtle
  window=turtle.Screen() #create window
  window.bgcolor("light yellow")
  window.title("new turtle window")


Output:


Example 2:

To Draw a square in turtle window

Program:


  import turtle
  window=turtle.Screen() #create window
  window.bgcolor("yellow")
  window.title("draw square")
  A=turtle.Turtle() #create turtle
  for i in range(4):
      A.forward(100) #move turtle forward
      A.right(90) #move turtle right
  turtle.done()#close turtle


Output:







More topic in Python

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send