0Pricing
Coding for Kids · Lesson

Bouncing Around

Make a shape bounce off the edges.

Bouncing Around is a free Coding for Kids lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Bounce, Bounce!

Hi animator! 🏀 Today we make our turtle bounce off the edges of the window!

Just like a ball in a room. 🎾

The Edges of the Window

The window has edges: left, right, top, bottom. 🪟

When the turtle reaches an edge, we want it to turn around!

Checking Position

We use t.xcor() to ask "where is the turtle left-to-right?" 📍

If that number gets too big, the turtle is near the edge!

Turning Around

To bounce, the turtle flips direction. We can use t.right(180) to turn all the way around. 🔄

A Simple Bounce

Here the turtle moves, and if it goes too far right, it turns around! 🏀

import turtle

t = turtle.Turtle()
for i in range(20):
    t.forward(20)
    if t.xcor() > 150:
        t.right(180)
turtle.done()

It Turned Back!

When the turtle passed 150, it spun around and came back! 🔄

That is a bounce!

The Magic Word if

We used if! 🤔

if means "only do this WHEN something is true". Here: only turn IF too far right.

Bouncing Both Ways

We can bounce off the left edge too! Check both sides. ↔️

import turtle

t = turtle.Turtle()
for i in range(30):
    t.forward(20)
    if t.xcor() > 150:
        t.right(180)
    if t.xcor() < -150:
        t.right(180)
turtle.done()

Back and Forth

Now the turtle bounces between both edges, back and forth! ↔️🏀

Just like a real bouncing ball.

How Real Games Work

Video game characters bounce off walls the same way! 🎮

Move, check the edge, turn if needed. You learned a real game trick!

Bounce Master!

You learned to check position with xcor() and bounce using if. 🏀🏆

Quick Check

Bounce quiz! 🏀

Bouncing Pro!

Fantastic! 🎉 Your turtle can bounce around.

Next lesson: make your very own moving scene! 🎬

Frequently asked questions

Is the “Bouncing Around” lesson free?

Yes — the full text of “Bouncing Around” is free to read here on the web, and the Coding for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO.

What will I learn in “Bouncing Around”?

Make a shape bounce off the edges. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Coding for Kids?

No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Bouncing Around” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Coding for Kids lesson?

Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Making Things Move
  2. Repeating Movement
  3. Bouncing Around
  4. Your Own Animation
← Back to Coding for Kids