🐒What is Turtle Graphics?

Turtle Graphics is a way to draw pictures and shapes by telling a “turtle” (a little triangle) what to do with code. The turtle can move forward, turn, and draw lines as it moves. This is a fun and visual way to learn programming using Python!

Try it out! Create a free account at Trinket.io and create a graphical representation of a building using turtle graphics. It should have a square shape, which you would make using a loop.

πŸ” Drawing a Square with a Loop

To draw a square, the turtle needs to:

  • Go forward (to draw a side)
  • Turn 90 degrees
  • Repeat 4 times to make all sides

Here is some sample code to get you started:

import turtle

# Set up the screen and turtle
t = turtle.Turtle()

# Optional: Choose a fill color
t.fillcolor("lightblue")

# Start filling in the shape
t.begin_fill()

# Draw a square
for i in range(4):
    t.forward(100)    # Move forward by 100 units
    t.right(90)       # Turn right 90 degrees

# End the fill
t.end_fill()
🎨 Filling with Color

To color your building:

  • Use t.fillcolor("yourColor") to pick a color.
  • Use t.begin_fill() before your loop.
  • Use t.end_fill() after the loop.
πŸ’‘ Be Creative!

After you draw your building, you can:

  • Add windows (smaller squares)
  • Draw a door
  • Add a roof (like a triangle)
  • Use different colors
  • Try t.penup() and t.pendown() to move without drawing

Did you know you can use Python and Turtle graphics to create beautiful art? All you need is a little imagination, functions and loops. Watch the video to see it in action! #Python #Coding #TurtleGraphics #LearnToCode

Latest Posts