First If
For absolute beginners

Your first if statement is the moment your code starts to think.

First If teaches the one idea that turns a script into a program: making a decision. Plain English, real examples, no computer science degree required.

Three deep guides. Zero jargon walls. Read one on your lunch break.

python
age = 15

if age >= 18:
    print("You can vote")
else:
    print("Not yet - come back in a few years")

The whole idea, in twenty seconds

An if statement is a code sentence that asks a yes/no question. If the answer is yes, a few lines run. If it is no, they are skipped. That is the entire concept — everything else is spelling.

01

Ask a question

A condition is any comparison that comes out true or false: age >= 18, pin == saved_pin, balance > price.

02

Run a block

Everything indented under the if belongs to it. If the answer is false, that block is skipped entirely and nothing inside it happens.

03

Add the other path

Add else and the program no longer has a silent gap: it does one thing or the other, always. That is a real decision.


Ask a question

Stuck on an exercise? Not sure why your code skipped a line? Send it over — a real answer beats another tutorial.

The most common thing we hear: “it works, but it never prints anything.” That is almost always a condition that was false when you thought it was true. Paste your code and we will point at the line.

Your message comes straight to the person who writes the guides. We answer real questions.

Powered by LunaNineAI.com

This is a demo version of this site.

Contact us to claim this site.