Getting Started with Python & Turtle Jump to this section
This lesson introduces what programming and Python are, shows how the Turtle graphics library works, and gives two easy ways to run Turtle code: using the playground on this site (no install), or running Python on your computer.
What is Python? Jump to this section
Python is a simple, widely used programming language that's great for beginners. The Turtle library is built into Python and makes visual programming easy by letting you control a "turtle" that draws as it moves.
Running Python code Jump to this section
- To keep things simple, you can just use the playground on this site: the editor here runs code in your browser so you do not need to install anything. It's the easiest way to try examples and follow along.
- If you want to run Python on your computer (good for saving files and projects): install Python and run scripts locally. See the setup steps in the Python beginner course: Python Beginner Intro/Setup
Your first Turtle program Jump to this section
Try this simple example in the playground or save it as turtle1.py and run it locally.
import turtle
screen = turtle.Screen()
screen.title("My First Turtle")
t = turtle.Turtle()
t.forward(50)
t.left(90)
t.forward(50)
turtle.done()
What this does:
import turtleloads the Turtle library.Screen()opens a drawing window.Turtle()creates the pen (the turtle) you control.forwardandleftmove the turtle and draw lines.turtle.done()keeps the window open until you close it.
Note: When using the Python playground on this site, you don't need
screen = turtle.Screen()orturtle.done(), this is just used when running the code on your own computer.
