Introduction to Python and Turtle
Setting Up Your Environment and Drawing Your First Shape
This is the first unit in my Python tutorial series. We're starting with the absolute basics: what programming is, how to set up Python on your machine, and your first program. By the end, you'll have a little turtle drawing shapes on screen.

What is Programming?
Programming is the process of creating instructions that computers can understand. Think of it like writing a recipe: you provide step-by-step directions, and the computer executes each step to produce a result. The language you write those instructions in matters, and Python is one of the best places to start.
Why Python?
Python is a high-level programming language, which means it reads more like English than machine code. High-level languages hide the complexity of what's happening inside the computer (the 1's and 0's) so you can focus on what you want to accomplish. Python's syntax is clean and straightforward, and it has a massive library of tools for everything from web development to data science to graphics.
Setting Up Python and VS Code
First, you need Python installed on your machine. Visit the official Python website and download the version for your operating system. For writing code, I recommend Visual Studio Code.
Download VS Code from the official website and install it. Once it's running, add the Python extension by opening the Extensions view (the icon on the sidebar, or Ctrl+Shift+X on Windows/Linux, Cmd+Shift+X on macOS). Search for "Python," select the one from Microsoft, and click Install.
Your First Program
Open VS Code and create a new file (Ctrl+N or Cmd+N). Save it as hello.py somewhere you'll remember. The .py extension tells VS Code this is a Python file.
In the editor, type:
print("Hello, world!")
Save the file, then click the green play button at the top right. Look at the Terminal panel at the bottom. You should see Hello, world! printed there. That's your first program running.
The Turtle Library
Turtle is a graphics toolkit built into Python. You control a cursor (the "turtle") that moves around the screen, leaving a trail as it goes. It's a great way to learn programming because you can see what your code is doing.
Create a new file called move_turtle.py and add this code:
import turtle
# Create a new turtle screen and set up the window
screen = turtle.Screen()
# Create a new turtle and assign it to a variable called "t"
t = turtle.Turtle()
# Set the turtle speed to the slowest setting to see it move
t.speed(1)
# Make the turtle draw a line by moving forward 100 units
t.forward(100)
# We're done, so let's wait until the window is closed
# Note: we're calling turtle.done() and not t.done() here. We'll
# explain why in future lessons.
turtle.done()
Run it. A window opens with a small arrow that draws a line from left to right. The window stays open until you close it. One thing to watch for: the program keeps running as long as that window is open. If you change your code and try to run again while the old window is still up, nothing will happen until you close it.
Project: Draw a Square
For the first project, let's draw a square. Create a file called draw_square.py:
import turtle
# Set up the window and its attributes
screen = turtle.Screen()
# Create a new turtle and assign it to a variable called "t"
t = turtle.Turtle()
# Draw the square
for _ in range(4):
t.forward(100) # Move forward by 100 units
t.right(90) # Rotate the turtle direction clockwise by 90 degrees
# We're done, so let's wait until the window is closed
turtle.done()
The turtle moves forward 100 units, turns right 90 degrees, and repeats four times. The result is a square. Don't worry if the for loop doesn't make sense yet. We'll cover that in detail later in the series. For now, just run it and watch the turtle work.
Programming takes practice. If something doesn't click immediately, that's normal. Keep at it.
In the next unit, we'll look at how Python stores information using variables and data types.