17 Sep Create and Run First Turtle Program
Let us run our first Turtle program. First, we installed Python in the previous lesson. While installing Python, we installed IDLE, which is a free IDE to run Python programs. We also saw that turtle is ready to use as soon as Python is installed by typing import turtle in the previous lesson:

To run our first Turtle program, let us create a new file in IDLE. Go to the File menu, click New File. Press CTRL+S and save the file as Demo1.py. To add the code in your first program, follow the steps below:
- Step 1: The program starts by importing the turtle module, which is a built-in Python library used for simple graphics and drawing.
- Step 2: It creates a drawing window using turtle.Screen(). This window acts as the canvas where the turtle will move and draw. The title of the window is set to “My First Turtle Program” to personalize it.
- Step 3: A turtle object is created using turtle.Turtle(). This object, named my_turtle, behaves like a pen that can move around the screen and draw lines.
- Step 4: The turtle is instructed to move forward by 100 pixels. As it moves, it draws a straight line on the canvas.
- Step 5: The program waits for a mouse click inside the window. Once clicked, the window closes automatically using exitonclick().
Note: As discussed, we will run our Python programs on IDLE.
Here is our complete Python Turtle program for which we discussed the steps above:
Demo1.py
# First Turtle Program
# Code by Studyopedia
import turtle
# Create a window for drawing
window = turtle.Screen()
window.title("My First Turtle Program")
# Create a turtle object
my_turtle = turtle.Turtle()
# Move the turtle forward
my_turtle.forward(100)
# Close the window on click
window.exitonclick()
Now, go to the Run menu and click Run Module. Run the program as shown below:

The following is the output:

If you liked the tutorial, spread the word and share the link and our website, Studyopedia, with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
- Generative AI Tutorial
- LangChain Tutorial
- RAG Tutorial
- Machine Learning Tutorial
- Deep Learning Tutorial
- Ollama Tutorial
- Retrieval Augmented Generation (RAG) Tutorial
- Copilot Tutorial
- Gemini Tutorial
- ChatGPT Tutorial
No Comments