Studio Matrx Monthly · Volume 1 · Issue 3 · August 2026
Amogh N P
 In loving memory of Amogh N P — Architect · Designer · Visionary 
Conditionals & BooleansLesson 2.1
PSD for Architecture, Planning & Urban Design/Module 2 · Control Flow & Collections

Lesson 2.1 · Control Flow & Collections

Conditionals & Booleans

Teaching code to make decisions - if this, then that - the way you already reason through a design

13 min Interactive lessonFree · open lessonByAmogh N P· Architect & interior designer
The hook

You already design by rules - if the room faces west, add shading; if the span is long, deepen the beam. Conditionals are simply those rules written so a computer can apply them.

A script that only does the same thing every time is a stapler. The moment a script can look at a value and choose what to do next, it becomes something closer to an assistant - it can sort, flag, filter and decide. That power comes from the conditional: `if` this is true, do that; otherwise, do something else.

You reason this way constantly. If a bedroom is below a minimum area, it fails the brief. If the finish is over budget, you specify an alternative. This lesson turns that everyday if-then instinct into three keywords - if, elif, else - built on top of the simplest data type in programming: the boolean, a value that is only ever True or False.

if = do it only when True. elif = otherwise try this. else = catch-all. First match wins.

The boolean: everything reduces to True or False

Before a program can decide, it needs something to decide on - and that something is a boolean, a value with exactly two states: True or False (capital T and F in Python; they are keywords, not strings). You rarely type True yourself. Instead you produce booleans by comparing things, and Python gives you six comparison operators that each answer a yes-or-no question:

python
area = 18
print(area >= 20)      # False  - is 18 at least 20?
print(area < 25)       # True
print(area == 18)      # True   - note: == compares, = assigns
print(area != 0)       # True   - not equal

The one that trips up every beginner is == versus =. A single = assigns a value (area = 18 puts 18 into area); a double == asks whether two things are equal and hands back a boolean. Mixing them up is one of the most common early errors, so read == in your head as the whole phrase 'is equal to'.

Comparisons work on more than numbers. Strings compare too - name == "kitchen" is True only when the text matches exactly, and Python is case-sensitive, so "Kitchen" == "kitchen" is False. Every one of these expressions collapses a real question about your design data into a single True or False, and that boolean is the fuel a conditional runs on.

EVERYTHING REDUCES TO TRUE / FALSEarea >= 20budget < costname == "kitchen"sockets != 0FalseTrueTrueTrueCOMBINE WITH and / or / notbig and sunny-> True only if BOTH are Truenear or affordable-> True if EITHER is TrueTruthiness: 0, "", [], None act as False; most other values act as True.
Zoom
Every condition a program tests reduces to a single boolean - True or False. Comparison operators turn questions about your design data (is this room big enough? is it a kitchen?) into that yes/no value, and and/or/not combine several of them. Truthiness lets ordinary values like 0 and an empty list stand in for False.

if / elif / else: the decision itself

A conditional wires a boolean to an action. The pattern reads almost like English:

python
area = 18

if area >= 20:
    tag = "large"
elif area >= 12:
    tag = "medium"
else:
    tag = "small"

print(tag)   # medium

Python checks each condition from the top. The first one that is True wins: its block runs, and every remaining branch is skipped. Here area >= 20 is False, so Python moves on; area >= 12 is True, so tag becomes "medium" and the else never even gets looked at. That top-to-bottom, first-match-wins behaviour is why order matters - if you tested >= 12 before >= 20, everything twelve or larger would be labelled medium and 'large' could never happen.

Three rules are worth fixing in your mind. First, only the if is required; elif (short for 'else if') and else are optional - you can have an if on its own, or an if with a single else, or a long chain of elifs. Second, else carries no condition; it is the catch-all that runs when nothing above matched. Third, you can chain as many elif branches as you need, which is how a script sorts rooms, budgets or materials into any number of categories with one clean structure.

IF / ELIF / ELSE FLOWarea = 18area >= 20 ?largearea >= 12 ?mediumtag = largetag = mediumelse: tag = smallTrueFalseTrueFalse
Zoom
How an if/elif/else chain flows. Python tests the conditions from the top and takes the first branch that is True, skipping the rest. Here area is 18: the large test fails, the medium test passes, and the small else is never reached. Change the order of the tests and rooms get mislabelled - first match always wins.

Indentation is not decoration - it is the syntax

In most languages, curly braces or keywords mark where a block of code begins and ends. Python uses indentation instead - the spaces at the start of a line are meaningful, not cosmetic. The lines indented under an if belong to that branch; when the indentation stops, the branch is over.

python
if area >= 20:
    tag = "large"
    print("needs two windows")   # still inside the if
print("done")                    # NOT inside - runs every time

The convention, followed everywhere, is four spaces per level. Do not mix tabs and spaces - Python will reject the file with an IndentationError, and this is one of the first errors every learner meets. The upside of this rule is real: Python code cannot look tidy while behaving otherwise, because the visual shape of the code is its logic. When you nest a conditional inside another (say, checking a room is large and then checking its orientation), each level steps in another four spaces, and the staircase of indentation shows you exactly how the decisions nest. Get in the habit now: let your editor insert four spaces on Tab, and treat the colon at the end of an if line as a promise that an indented block follows.

Nesting puts this to work. When one decision only makes sense inside another - a room is large, and then it faces west - the inner if sits inside the outer block, indented one more level, and its four extra spaces are a direct picture of the dependency:

python
if area >= 20:
    if facing == "west":
        print("large west room: add shading")

Read the depth of the indentation and you can see at a glance which decisions hang off which. That visual honesty is the quiet payoff of Python's rule: badly structured logic cannot hide behind tidy-looking braces, because here the shape on the page and the shape of the logic are one and the same thing.

The colon says: an indented block follows. Four spaces = one level. Tabs + spaces = error.

Combining conditions with and, or, not

Real design rules rarely hinge on a single fact. A room might need extra ventilation only if it is both large and a kitchen; a layout might be acceptable if it is either cheap or fast to build. Python expresses this with three plain-English operators - and, or, not - that combine booleans into bigger booleans:

python
area = 22
room = "kitchen"

if area >= 20 and room == "kitchen":
    print("large kitchen: add a second exhaust")

if room == "bath" or room == "utility":
    print("wet area: waterproof the floor")

if not room == "corridor":
    print("habitable space")

and is strict - the whole expression is True only when both sides are True. or is generous - True if either side is. not simply flips a boolean, turning True into False and back. There is also a subtler idea called truthiness: Python will treat many non-boolean values as True or False when you use them where a condition is expected. Zero, an empty string "", an empty list [], and the special value None all count as 'falsy'; almost everything else is 'truthy'. This lets you write natural checks like if rooms: to mean 'if the list has anything in it', or if not name: to mean 'if the name is missing or blank'. Used well, truthiness makes conditions read cleanly; used carelessly it hides bugs, so when you mean 'is this list empty', prefer the explicit if len(rooms) == 0: until the shorthand feels natural.

EVERYTHING REDUCES TO TRUE / FALSEarea >= 20budget < costname == "kitchen"sockets != 0FalseTrueTrueTrueCOMBINE WITH and / or / notbig and sunny-> True only if BOTH are Truenear or affordable-> True if EITHER is TrueTruthiness: 0, "", [], None act as False; most other values act as True.
Zoom
Every condition a program tests reduces to a single boolean - True or False. Comparison operators turn questions about your design data (is this room big enough? is it a kitchen?) into that yes/no value, and and/or/not combine several of them. Truthiness lets ordinary values like 0 and an empty list stand in for False.

Patterns worth memorising: chained comparisons, guard clauses, the one-line if

Once the basic shapes are comfortable, a few conditional patterns recur so often that they are worth learning by name. The first is the chained comparison, a piece of Python that reads exactly like mathematics. Where many languages force you to write area >= 12 and area < 20, Python lets you say it the natural way:

python
area = 15
if 12 <= area < 20:
    print("medium room")

This is not just shorter - it is clearer, and it says precisely what a designer means by 'between 12 and 20'. You can read 12 <= area < 20 aloud as 'twelve is at most the area, which is less than twenty', and the whole thing evaluates to a single boolean.

The second pattern is the guard clause: checking for the bad or special case first and dealing with it at once, rather than wrapping all your real logic inside a deeply nested if. Compare a nested style with a guarded one:

python
name = ""
if not name:
    print("skip: unnamed room")
else:
    print(f"processing {name}")

Guarding keeps the main logic flat and readable, and it pairs beautifully with the continue you will meet in loops - test for the case you want to skip, handle it, and move on. Deeply nested conditionals, by contrast, march further and further to the right and quickly become hard to follow; if you find yourself three or four levels deep, it is usually a sign to guard the exceptions early or to split the work into a function (Module 3).

The third is the conditional expression, often called the ternary - a way to choose between two values on a single line:

python
area = 18
tag = "large" if area >= 20 else "small"

Read it as 'large if the area is at least 20, otherwise small'. It is perfect for a simple two-way choice you want to assign to a variable, and it reads cleanly inside a list comprehension too. Do not stretch it to cover three or more cases - that is what the full if/elif/else chain is for, and forcing a many-way decision into a one-liner sacrifices exactly the readability that makes Python worth using. Reach for the ternary for genuine two-way choices, the chain for many-way ones, and a guard clause whenever a special case deserves handling up front. One last habit: never compare a boolean to True or False explicitly. Write if is_wet: and if not is_wet:, never if is_wet == True: - the comparison is redundant noise, since is_wet is already a boolean. Small as it is, dropping that habit is a mark of code that reads the way its author thinks.

Taken together, the conditional gives your scripts something close to judgement - not the deep judgement of design, which stays firmly yours, but the mechanical judgement of applying a rule the same way every single time. That reliability is the whole point. A tired designer misreads a schedule at the end of a long day; a conditional does not. Once you can express your rules as if/elif/else, you have handed the boring, error-prone half of decision-making to something that never gets bored, never skips a row, and never gets it wrong.

Concepts & keywords in this lesson

if / elif / else

The conditional statement - run a block only when a condition is True

First-match-wins, top to bottom. Only if is required; elif and else are optional additions to it.

bool (True / False)

The two-state data type every condition reduces to

Produced by comparisons. Capitalised keywords in Python - True and False, never true/false.

Comparison operators

== != < > <= >= to ask yes/no questions of your data

== compares, = assigns - the single most common beginner mix-up. String comparison is case-sensitive.

and / or / not

Boolean operators that combine conditions

and needs both True; or needs either; not flips. They read like English and mean what they say.

Truthiness

Non-boolean values treated as True/False in a condition

0, empty string, empty list and None are falsy; most else is truthy. Powerful but easy to misread - be explicit when in doubt.

Hands-on workshop

Workshop - a room classifier

Write a small script that takes a room's area and name and prints a sensible tag for it, exactly the kind of rule engine that later drives an automatic schedule. You will practise comparisons, an if/elif/else chain, and combining conditions.

Python 3 in any editor or notebook (installed in Module 1). No libraries needed.

Given & goal
Goal: classify one room by area and type using conditionals
Inputs: an area number and a room name (as variables)
Time: ~25 minutes
  1. 1Create two variables at the top: area = 18 and room = "kitchen". You will change these to test different cases.
  2. 2Write an if/elif/else chain that sets size = "large" when area is 20 or more, "medium" when it is 12 or more, and "small" otherwise. Print the size.
  3. 3Add a combined condition: if area >= 15 and room == "kitchen": print a note that the kitchen is large enough for an island. Test it against your values.
  4. 4Add a wet-area rule using or: if the room is "bath" or "utility", print "waterproof the floor". Change room to test both.
  5. 5Now break it on purpose: set area = "18" (a string, in quotes) and run it. Read the error, then fix it back to a number - a first taste of why data types (Module 1) matter to conditionals.
  6. 6Bonus: retype the chain but put the >= 12 test BEFORE the >= 20 test and observe how every large room is now mislabelled 'medium'. Explain to yourself why order matters.

You’ll walk away with
A short script that prints a size tag and any applicable design notes for a room, correct across at least four test cases (small/medium/large, kitchen, and a wet room), plus a one-line note on what breaking the type or the order taught you.

The worked example

Three altitudes on the same idea

Read the band that fits you — or all three.

For the architectAutomate busywork & build custom tools

Conditionals are how a script starts checking your work. A model audit is a stack of if-statements: if a room has no name, flag it; if a door is under 900mm, flag it; if a space exceeds an area limit, tag it for review. The same logic drives automatic classification - sorting a schedule of hundreds of spaces into habitable, service and circulation categories in a heartbeat, applying exactly the rules you would apply by eye, but without missing one at 6pm on a deadline.

For the interior designerScripts for data, schedules & layouts

Your specifications are conditionals in disguise. If a finish exceeds the budget line, substitute the alternative; if a room is wet, the flooring rule changes; if a client selects the premium package, swap the whole ironmongery set. Written as code over an FF&E list, these rules re-price and re-spec a scheme in seconds when a client changes their mind - which they will. Learning if/elif/else is the point where your material and finish logic becomes something a script can apply for you.

For the studentA hireable computational skill

This is where programming stops being arithmetic and starts being logic. Every algorithm you will meet later - sorting, searching, generating form, optimising a layout - is built from decisions, and decisions are conditionals. Master the flow of if/elif/else and the honest handling of booleans now, on small design examples you understand, and the harder modules on data, geometry and generative design will feel like new vocabulary on grammar you already own.

Misconception check

You should use lots of separate if-statements, one after another, to cover every case.

Separate ifs and a single if/elif/else chain look similar but behave differently, and the difference bites beginners. A chain stops at the first match - once a branch is True, the rest are skipped - so each item lands in exactly one category. A stack of independent ifs is re-evaluated every time, so an item can trigger several blocks, and a value you changed in one if can flip a later one. When your categories are mutually exclusive (a room is small OR medium OR large, never two at once), use one elif chain with a final else - it is clearer, faster, and impossible to fall through by accident. Reach for separate ifs only when the conditions are genuinely independent and more than one can legitimately apply.
Try it

Do it yourself

Reason these through - predict before you run.

  1. 1What is the difference between = and ==, and which one belongs inside an if condition?
  2. 2In an if/elif/else chain, if two conditions are both True, which block runs?
  3. 3Write the condition for 'the room is larger than 10 sqm AND it is not a corridor'.
  4. 4Which of these are falsy in Python: 0, "0", [], "kitchen", None?
  5. 5Why does Python raise an error if you mix tabs and spaces to indent a block?
Take this with you

The one line to carry out

A conditional wires a boolean to an action: comparisons turn your design data into True/False, and `if/elif/else` chooses what happens next - first match wins, indentation marks the block. This is the move that turns a script from a calculator into something that judges.
Take it further
References & further reading

Peer-reviewed journals & authoritative standards

  1. 01Conditional (computer programming)Wikipedia, 2026.
  2. 02Boolean data typeWikipedia, 2026.
  3. 03Control flowWikipedia, 2026.
  4. 04The Python TutorialPython Software Foundation, 2026.
Related lessons
Recap
Booleans are values that are only True or False, produced by comparing things with ==, !=, <, >, <=, >=. A conditional runs a block only when its condition is True, and if/elif/else checks top to bottom, stopping at the first match. Indentation - four spaces - defines the block, and and, or, not combine conditions the way your design rules combine facts.
Carry forward →

A conditional decides once. But real leverage comes from doing something to _many_ items - every room in a schedule, every file in a folder. Next we meet the loop, the engine that applies your logic across a whole collection.

A

The author

Amogh N P

Architect, interior designer, and creative polymath. Studio Matrx began in his notebooks — his vision of design made honest, useful, and open to everyone. Its Academy is written and taught in his memory, and free, forever.

More about Amogh →