0Pricing
Coding for Kids · Lesson

Making a Secret Number

Pick a random number.

Making a Secret Number 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.

Let's Make a Game! 🎮

Hi game maker! 🎮 We're building a fun Guess the Number game! 🔢

The computer picks a SECRET number, and the player tries to guess it! First, let's learn how to make a secret number!

print('I am thinking of a secret number... 🤫')

Random Means Surprise! 🎲

A random number is a surprise number — even the computer doesn't know it until it picks! 🎲

This makes every game different and exciting!

print('Every game will be a surprise! 🎉')

Import the random Helper 📦

To make random numbers, we need a special toolbox called random. We bring it in with import random! 📦

import random
print('Random toolbox is ready! 🧰')

Pick a Random Number 🎯

The tool random.randint(1, 10) picks a whole number between 1 and 10! 🎯 The 1 and 10 are BOTH possible.

import random
secret = random.randint(1, 10)
print('Secret number:', secret)

Run It Again and Again! 🔄

Each time you run randint, you may get a DIFFERENT number! Try running this a few times. 🔄

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

Keep It Secret! 🤫

In a real game, we would NOT print the secret. We just save it in a box for later. 🤫

Here we peek, but shhh, don't tell the player!

import random
secret = random.randint(1, 10)
print('(Secret saved! I won\'t tell the player.) 🤐')

Choose the Range 📏

Want a harder game? Use a bigger range, like 1 to 100! 📏 Want an easier one? Try 1 to 5!

import random
secret = random.randint(1, 100)
print('Secret is somewhere from 1 to 100! 😮')

A Dice Roller! 🎲

Fun fact: random.randint(1, 6) is like rolling a dice! 🎲 Let's roll!

import random
roll = random.randint(1, 6)
print('You rolled a', roll, '🎲')

Random Choice From a List 📋

The random toolbox can also PICK from a list! random.choice grabs one item at random. 📋

import random
fruits = ['🍎', '🍌', '🍇']
print('Random fruit:', random.choice(fruits))

Set Up Our Game Secret 🎮

For our guessing game, let's pick a secret between 1 and 20. Not too easy, not too hard! 🎮

import random
secret = random.randint(1, 20)
print('I picked a secret number from 1 to 20! Can you guess it? 🤔')

Surprise Master! 🚀

Now you can make random numbers for ANY game! 🚀 Change the range below and run it a few times to see surprises!

import random
secret = random.randint(1, 50)
print('My new secret is ready! 🤫')

Quick Check! 🧠

Test your random number knowledge! 🎲

Secret Number Champion! 🎉

Awesome! 🎉 You can make secret numbers!

  • import random brings the toolbox 📦
  • random.randint(1, 10) picks a surprise number 🎲
  • Bigger range = harder game 📏
  • Keep the secret hidden from the player! 🤫

Next: asking the player to guess! ❓

import random
secret = random.randint(1, 20)
print('Game ready! Secret picked! 🎮')

Frequently asked questions

Is the “Making a Secret Number” lesson free?

Yes — the full text of “Making a Secret Number” 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 “Making a Secret Number”?

Pick a random number. 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 “Making a Secret Number” 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 a Secret Number
  2. Asking for Guesses
  3. Higher or Lower
  4. You Win!
← Back to Coding for Kids