🎨 Lesson 5: Drawing with Turtle

Welcome to your first graphics lesson! Today, we will explore Python's turtle module, which lets you draw on the screen using code.

πŸ“˜ What is Turtle?

turtle is a built-in Python library that provides a way to draw using code. It opens a window and shows a turtle icon that you can control to draw shapes and patterns.

It’s especially useful for beginners to understand loops, movement, and even angles while creating visual feedback instantly.

πŸ”§ Setting Up Turtle

To use turtle, you don't need to install anything if you're using standard Python. Just use import turtle in your code. Make sure you're running your script in a Python environment that supports graphical output (like a local IDE, not most online editors).

πŸ’» Basic Example

import turtle

# Create screen and turtle object
window = turtle.Screen()
my_turtle = turtle.Turtle()

# Draw an L-shape
my_turtle.forward(100)
my_turtle.left(90)
my_turtle.forward(100)

# Keep the window open
window.mainloop()

This code opens a window and makes the turtle draw an L-shape.

🧠 Try It Yourself

πŸ“˜ Tips & Tricks

πŸ“ Assignment

Write a Python program that uses the turtle module to draw a simple house:

← Back to Dashboard