Kids Coding

Project: Number Guess

The computer picks a number. You guess. if tells you too high or too low.

KidsBasicProject: Number Guess

Too high, too low

The computer keeps a secret number. You guess. if says whether you won, went too high, or went too low.

One guess

secret = 7
guess = 4

if guess == secret:
    print("You got it")
elif guess < secret:
    print("Too low")
else:
    print("Too high")

elif means else if

When there are three paths, use if, then elif, then else. Python picks the first yes and skips the rest.

Try more than one guess

Here the guesses are saved in the program so it runs in the editor. Change guess and run again.

Change this number

secret = 7
guess = 7

print("You guessed", guess)
if guess == secret:
    print("Yes! It was", secret)
elif guess < secret:
    print("Too low. Try a bigger number.")
else:
    print("Too high. Try a smaller number.")

Later, Intermediate will add random and a while loop so the secret changes and you can guess until you hit it.

Real life

A jar of sweets at a party. How many inside?

You guess. Someone says too high or too low. if is that voice.

Sweets in the jar

jar = 18
guess = 12
print("You guessed", guess)
if guess == jar:
    print("You win the jar")
elif guess < jar:
    print("Too low — there are more")
else:
    print("Too high — fewer than that")

Change one word. Run it. That is how this idea shows up outside the lesson.

Try it

Exercise 1: Set secret to 3 and guess to 10. Print Too high using if / else.

Show solution
secret = 3
guess = 10
if guess == secret:
    print("Yes")
else:
    print("Too high")

FAQ: Project: Number Guess

Common questions about this page.

What is StudyGrid Kids?

StudyGrid Kids is a free coding path for children: Basic, Intermediate, and Advanced. Lessons use Python in the browser. No account and no install.

Should I run project: number guess examples locally for better learning?

Yes. Use the browser editor on StudyGrid for a quick check, then Download the example and run it on your computer. Local runs show real errors and the real toolchain, which is one of the fastest ways to learn project: number guess in this Kids Coding Python lesson (Project: Number Guess).

Which kids level should we start with?

Start at Basic if the child has never written code. Choose Intermediate if they can print, use variables, and write a simple if. Choose Advanced if they already use loops and lists.

Do kids need an account or an app?

No. Kids pages are public. Code runs in the Try Python editor at /try. We do not ask children for a name or an email.

What language do kids learn?

Python, with a first HTML page in Intermediate and Advanced. After Advanced, the main Python tutorial is the next step.

Is the kids coding track free?

Yes. The Kids home, the three levels, and the Python editor on StudyGrid (studygrid.in) are free.