0Pricing
Coding for Kids · Lesson

The random Module

Make surprises.

The random Module is a free Coding for Kids lesson on CoddyKit — lesson 1 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.

Lucky Surprises! 🎲

Computers can make surprises using the random module. Like rolling dice or shuffling cards! 🃏

Import It First 📦

Before using random, we import it. Think of it like opening a toy box!

import random
print("random is ready!")

Roll a Dice 🎲

random.randint(1, 6) picks a number from 1 to 6, like a dice!

import random
print(random.randint(1, 6))

Run It Again 🔁

Each time you run it, you might get a different surprise!

import random
print(random.randint(1, 6))
print(random.randint(1, 6))

Pick from a List 🎁

random.choice grabs a random item from a list!

import random
colors = ["red", "blue", "green"]
print(random.choice(colors))

A Coin Flip 🪙

Flip a coin by choosing between two things!

import random
print(random.choice(["Heads", "Tails"]))

Random Decimal 💧

random.random() gives a tiny number between 0 and 1.

import random
print(random.random())

Shuffle a List 🔀

random.shuffle mixes up a list like shuffling cards!

import random
cards = [1, 2, 3, 4]
random.shuffle(cards)
print(cards)

A Magic 8 Ball 🎱

Pick a random reply for fun!

import random
replies = ["Yes!", "No!", "Maybe!"]
print(random.choice(replies))

Use the Surprise 🎉

Save a random number to use later.

import random
luck = random.randint(1, 10)
print("Your lucky number:", luck)

Why Random? 💡

Random makes games fun and unpredictable! Dice, card shuffles, and lucky draws all use it. 🎮

Quick Check ✅

Lucky brain snack! 🍪

Surprise Star! 🌟

You learned to import random and make surprises with randint, choice, and shuffle. Let the games begin! 🎲🎉

Frequently asked questions

Is the “The random Module” lesson free?

Yes — the full text of “The random Module” 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 “The random Module”?

Make surprises. 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 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “The random Module” 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. The random Module
  2. Random Numbers
  3. Random Choices
  4. A Fortune Teller
← Back to Coding for Kids