Kids Coding

Yes or No (If)

if and else pick a path. Compare two values. Print a different message.

KidsBasicYes or No (If)

Pick a path

if checks a yes-or-no question. If the answer is yes, Python runs the indented lines. else is the other path.

Password door

word = "open"
if word == "open":
    print("Come in")
else:
    print("Stay out")

Compare

CheckMeaning
==equal to
!=not equal to
<less than
>greater than

= puts a value in a box. == asks “are these the same?” Mixing them up is a common first bug.

Indentation is the block

The lines under if must be indented (usually four spaces). That indent is how Python knows which lines belong to the if.

A number check

score = 12
if score >= 10:
    print("You passed")
else:
    print("Try again")

Real life

Looking out the window before you leave.

If it is raining, take a coat. Else, leave it. Two paths. One check.

Coat or not

weather = "rain"
if weather == "rain":
    print("Take the coat")
else:
    print("Just a jumper")

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

Try it

Exercise 1: If age is 10 or more, print You can ride. Otherwise print Not yet. Try both values.

Show solution
age = 10
if age >= 10:
    print("You can ride")
else:
    print("Not yet")

FAQ: Yes or No (If)

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 yes or no (if) 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 yes or no (if) in this Kids Coding Python lesson (Yes or No (If)).

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.