Studio Matrx Monthly · Volume 1 · Issue 3 · August 2026
Amogh N P
 In loving memory of Amogh N P — Architect · Designer · Visionary 
Numbers, Strings and OperatorsLesson 1.3
PSD for Architecture, Planning & Urban Design/Module 1 · Python Fundamentals

Lesson 1.3 · Python Fundamentals

Numbers, Strings and Operators

Doing arithmetic, building text, comparing values, and converting between them - turning stored values into results

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

Stored values just sit there. Operators are the verbs - add, multiply, join, compare - that turn your named boxes into answers.

You can now store the four kinds of value. This lesson is about doing things with them: the operators and functions that turn length and width into an area, glue a room name and a number into a clean label, ask whether one value is bigger than another, and translate between the text people type and the numbers you calculate with.

These are the everyday verbs of programming, and they are where scripts start to feel genuinely useful. By the end you can compute a real quantity, format it into a sentence a client could read, and handle the constant friction between text and numbers - which is, quietly, the source of most beginner bugs.

/ float, // whole-fit, % leftover. f-strings for reports. == asks, = sets. Convert text<->number at every edge.

Arithmetic operators - Python as a calculator

Numbers combine with arithmetic operators, most of which look exactly as you would expect: + add, - subtract, * multiply, / divide. Three more are worth knowing because they solve real problems:

python
wall = 240        # wall length in cm
tile = 18         # tile size in cm

print(wall / tile)   # 13.333333333333334  -- exact division, a float
print(wall // tile)  # 13    -- floor division: whole tiles that fit
print(wall % tile)   # 6     -- modulo: the leftover cm at the end
print(2 ** 10)       # 1024  -- power: 2 to the 10th

/ always gives a float, even when it divides evenly (10 / 2 is 5.0). // is floor division - it divides and throws away the remainder, perfect for 'how many whole tiles fit along this wall'. % is modulo - the remainder left over - which answers 'how much offcut is at the end' and, later, powers every-nth-item patterns. ** is exponent, for powers.

Order of operations follows normal maths: * and / happen before + and -, and parentheses force the order you want. This matters:

python
print(2 + 3 * 4)      # 14, not 20 -- multiply first
print((2 + 3) * 4)    # 20 -- parentheses first

When a calculation has more than two steps, add parentheses even where they are technically optional - they make your intent obvious and prevent a whole class of quiet arithmetic bugs.

Two everyday points finish the picture. First, integers and floats mix freely: 10 * 1.08 gives the float 10.8, because the moment a float enters the sum the result becomes a float - which is usually what you want for measurements and money. Second, the self-updating shorthand from the last lesson applies here too, and you will lean on it hard: total += price adds price onto total in place, subtotal *= 1.18 bumps a figure up by a tax rate, and so on. These +=, -=, *= operators are just tidy ways of writing total = total + price, and they read cleanly when a value accumulates. Keep parentheses around anything you would pause to check by hand, prefer floats wherever fractions are possible, and Python behaves as a completely reliable calculator.

OPERATORS: DO MATH, ASK QUESTIONSARITHMETIC (make a number)a + badda - bsubtracta * bmultiplya / bdivide (float)a // bfloor dividea % bremaindera ** bpowerCOMPARISON (make True/False)a == bequal?a != bnot equal?a > bgreater?a < bless?a >= bat least?a <= bat most?One = assigns; two == asks. Mixing them up is themost common beginner bug.
Zoom
Two families of operator. Arithmetic operators (left) combine numbers into a new number - including // for the whole count that fits and % for the remainder. Comparison operators (right) ask a yes/no question and return True or False, the fuel for decisions. Remember: one = assigns a value, two == asks whether values are equal.

Strings - creating, joining and formatting text

Text is a string, and strings have their own operators. + between two strings concatenates them - joins them end to end - and * repeats one:

python
first = "Master"
last = "Bedroom"
name = first + " " + last   # "Master Bedroom" -- note the space string
rule = "-" * 20             # "--------------------" a divider line

Gluing strings with + gets clumsy fast, especially when you mix in numbers - and you cannot + a string and a number directly at all. The modern, far cleaner way to build text is the f-string: put the letter f before the opening quote, and then drop any expression inside {curly braces} right in the text. Python evaluates what is in the braces and slots the result in:

python
room = "Kitchen"
area = 12.5
print(f"The {room} is {area} square metres.")
# The Kitchen is 12.5 square metres.

rate = 1450
print(f"Tiling cost: {area * rate:.0f} rupees")
# Tiling cost: 18125 rupees

That second example shows two things f-strings do beautifully: you can put a whole calculation inside the braces, and you can format the result with a colon code - :.0f means 'show as a float with zero decimal places', :.2f means two, and :, adds thousands separators. F-strings are how you turn raw numbers into sentences and reports a human can read, and you will reach for them in almost every script you write.

When a piece of text runs long or needs to span several lines - a multi-line note, a little report block - wrap it in triple quotes, """like this""", and it keeps every line break you type:

python
report = f"""Room: {room}
Area: {area} sqm
Status: ready to tile"""
print(report)

Triple-quoted strings are handy for anything with structure, and you will see them again as the standard way to document what a function does in Module 3. For now, note the two tools: single-line f-strings for slotting values into a sentence, and triple quotes when the text itself has shape.

String methods - built-in text tools

Strings come with a toolkit of built-in actions called methods. You call a method by writing the string (or its variable), a dot, the method name, and parentheses - text.method(). They are how you clean and reshape the messy text that arrives from files, spreadsheets and people:

python
raw = "  Oak Flooring  "
print(raw.strip())        # "Oak Flooring" -- trims outer spaces
print(raw.strip().upper())# "OAK FLOORING"
print(raw.strip().lower())# "oak flooring"
print("bedroom".replace("bed", "bath"))  # "bathroom"
print("A-101,A-102,A-103".split(","))    # ['A-101', 'A-102', 'A-103']

strip() removes surrounding whitespace - invaluable, because data from spreadsheets is full of stray spaces that break comparisons. upper() and lower() change case, which is the standard trick for comparing text reliably (more in the next section). replace() swaps one piece of text for another. split() breaks a string into a list at a separator - here turning a comma-separated line into separate drawing numbers, a first taste of the list you meet in Module 2.

Notice you can chain methods - raw.strip().upper() strips first, then uppercases the result - because each method hands back a new string for the next to act on. Two more you will use often: "48".isdigit() asks whether a string is all digits (handy before converting user input), and len("oak") reports a string's length (here 3). Another everyday check is the in keyword, which tests whether one piece of text appears inside another: "oak" in "oak flooring" is True. That is exactly how you filter for, say, every finish description mentioning 'timber'. Between these, an f-string, and the cleaning methods above, you have most of day-to-day text wrangling covered. You do not memorise the list; you learn that the toolkit exists and look up the exact name when you need it - your editor will even suggest the methods when you type a dot after a string.

Comparison operators - asking yes/no questions

To make decisions, code has to ask questions, and the answer to a question is a bool - True or False. Comparison operators produce those answers:

python
area = 18
print(area > 15)     # True   -- greater than
print(area < 10)     # False  -- less than
print(area >= 18)    # True   -- greater than or equal
print(area == 18)    # True   -- equal? (two equals signs!)
print(area != 20)    # True   -- not equal

The operators are >, <, >=, <=, == and !=. Every one of them evaluates to True or False, which is exactly what the if statements of Module 2 need to decide what to do. The single most common beginner bug lives here: `=` assigns a value, but `==` asks whether two values are equal. Writing if area = 18 is an error; you mean if area == 18. One equals sets, two equals ask - burn that in now and save yourself hours later.

Comparisons work on strings too, alphabetically, and this is where case bites you:

python
print("oak" == "Oak")            # False -- capital O differs!
print("oak" == "Oak".lower())   # True  -- normalise case first

Because "oak" and "Oak" are literally different text to a computer, comparing text you did not type yourself almost always means lowercasing both sides first with .lower(). That single habit prevents a mountain of 'but they look the same!' confusion when you start filtering real data.

Comparisons rarely travel alone. Real decisions combine them - area over 15 **and** it is a wet area - and Python spells those joins with the plain English words and, or and not. You will meet them properly in Module 2 alongside if, but the idea is intuitive already: area > 15 and is_wet_area is True only when both parts are true, or needs just one, and not flips a True to False. There is even a neat shorthand Python allows that other languages do not - 10 < area < 20 reads exactly as the maths does and asks whether area sits between the two. Every one of these still boils down to producing a single True or False, which is all a decision needs.

Converting between text and numbers

Text and numbers are different types, and Python will not silently guess between them. "12" is text; 12 is a number; "12" + 3 is an error, not 15. This trips up every beginner, because the difference is invisible on screen. The fix is deliberate type conversion with three built-in functions:

python
int("12")     # 12    -- text -> whole number
float("2.5")  # 2.5   -- text -> decimal number
str(54.0)     # "54.0"-- number -> text

int() turns text (or a float) into a whole number, float() into a decimal, and str() turns a number into text. You need these constantly at the two edges of a script: input almost always arrives as text (the input() of the next lesson, or a cell from a spreadsheet) and must be converted before you can calculate, and output often means gluing numbers into text for a message.

Watch what goes wrong without conversion, and right with it:

python
qty = "3"                 # came in as text
# total = qty * 1450      # would give "314501450..." nonsense or an error
total = int(qty) * 1450   # convert first -> 4350, correct
print("Total: " + str(total))   # convert back to glue into text

One caution: conversion must make sense. int("3") works, but int("three") or int("3.5") raises a ValueError, because that text is not a plain whole number. In real scripts you check first (with .isdigit(), or by handling the error, which Module 3 covers) - but the core discipline is simple and worth forming now: convert text to a number before you calculate, and a number back to text before you join it into a message.

It helps to picture the whole shape of a script through this lens: text comes in at one edge, you convert it to numbers, you do the real arithmetic and text-building in the middle, and you convert back to text to send results out. The numeric core is where the actual work happens; conversion is the customs check at each border. Get into the habit of asking, at every point a value enters or leaves your program, 'is this text or a number right now?' - and reaching for type() when you are unsure. That one reflex dissolves most of the confusion beginners have with data, and it is the exact discipline that keeps the pandas work in Module 4 from tripping over columns that quietly arrived as text.

TEXT AND NUMBERS ARE DIFFERENT THINGS"12"str (text)12int (number)int("12")str(12)"12" + "3" is "123" (glued text). 12 + 3 is 15 (added numbers). Convert first, then combine.
Zoom
Text and numbers are different types, even when they look alike. "12" is a string; 12 is an int. int() converts text to a number so you can calculate; str() converts a number to text so you can join it into a message. Convert at every input and output edge - joining text with + concatenates, while adding numbers with + sums.
Operators & functions in this lesson

// and %

Floor division and modulo (remainder)

// gives whole tiles that fit; % gives the leftover. Together they solve grid and offcut problems.

f-string

f"...{expression}..." text with values slotted in

The clean way to build text from values, with format codes like :.2f and :, for readable output.

string methods

.strip() .lower() .upper() .replace() .split()

Built-in text tools for cleaning and reshaping messy data; chainable, each returns a new string.

== vs =

Equality test vs assignment

Two equals asks a question (returns a bool); one equals stores a value. Mixing them is the classic bug.

int() / float() / str()

Convert between text and numbers

Convert input text to a number before calculating; convert numbers back to text before joining into a message.

Hands-on workshop

Workshop - a formatted tiling estimator

Combine everything: arithmetic to compute a quantity, floor division and modulo for whole-tile logic, conversion to handle text-as-number, and an f-string to present the result as a clean sentence.

Python 3 and an editor. No libraries needed.

Given & goal
Goal: compute a tile count and cost and print it as a readable report line
Inputs: a wall length and height, a tile size, a unit rate
Time: ~30 minutes
  1. 1In tiles.py, set named variables for wall width and height (floats, in cm), tile size (int, cm), and rate per tile (int). Compute wall area and tile area.
  2. 2Use floor division to find how many whole tiles fit across the width and up the height, then multiply for a total tile count; use modulo to report the leftover cm at each edge.
  3. 3Compute total cost as tile count times rate, then add 10 percent for breakage using * 1.10.
  4. 4Print a single f-string report: something like f"{tiles} tiles needed, cost {cost:,.0f} (incl. breakage)", formatted with no stray decimals.
  5. 5Simulate messy input: set the rate as a string "1450", watch the cost break, then fix it with int() - and add a comment explaining why conversion was needed.

You’ll walk away with
A `tiles.py` that reads named inputs, uses //, % and * to compute a whole-tile count and a breakage-adjusted cost, and prints one cleanly formatted f-string report line - plus a comment showing the string-to-number fix.

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

F-strings and clean arithmetic turn a script into a report generator. A few lines can take floor areas and rates and emit a formatted cost line, or a room-by-room summary, ready to paste into a note - f"{area:,.1f} sqm at {rate}/sqm = {area*rate:,.0f}". The floor-division and modulo operators are exactly the tools for grid and tile-count logic you will formalise when you reach geometry in Module 5.

For the interior designerScripts for data, schedules & layouts

This lesson is the heart of quantity and spec work. Concatenating and formatting text builds tidy FF&E and finish descriptions; the string methods - strip, lower, replace, split - clean the inconsistent text that spreadsheets and supplier lists are full of; and int()/float() conversion is what makes a quantity typed as text actually add up. Modules 4 and 8 scale this to whole schedules, but the moves are all here.

For the studentA hireable computational skill

Operators and conversion are the fundamentals every technical interview and studio task assumes. The = versus == distinction and the text-versus-number gap are the two errors you will hit most in every language, so meeting them here on friendly ground pays off everywhere. Practise formatting numbers with f-strings until it is automatic; clear, readable output is a surprisingly large part of looking competent.

Misconception check

If a value looks like a number on screen, Python treats it as a number - so `"12" + "3"` should give 15.

Appearances lie, and this is the single most common source of early bugs. Whether a value is a number or text is decided by its type, not by how it looks printed, and quotes make it text. So "12" is a string, and + between two strings concatenates them: "12" + "3" is "123", glued end to end, not 15. Meanwhile 12 + 3 (no quotes) is genuine addition giving 15. The pattern to internalise: values arriving from outside your program - user input, spreadsheet cells, file text - are almost always strings, even when they look numeric, and you must convert them with int() or float() before doing maths. When arithmetic gives you a weirdly long 'number' or an error about mixing types, suspect a string masquerading as a number and check with type().
Try it

Do it yourself

Predict each result, then run to confirm - the surprises are the lesson.

  1. 1What are 17 // 5 and 17 % 5, and what real question does each answer for a tile run?
  2. 2Write an f-string that prints Area: 12.50 sqm from a variable area = 12.5.
  3. 3Why is "5" + "3" equal to "53" and not 8? How do you get 8?
  4. 4What does " Teak ".strip().lower() produce, and when is that useful?
  5. 5Explain the bug in if room_area = 20: and how to fix it.
Take this with you

The one line to carry out

Operators are the verbs of code: arithmetic (with // and % for whole-fit and leftover) computes numbers, f-strings build readable text, comparison operators produce True/False for decisions, and int()/float()/str() bridge the constant gap between text and numbers.
Take it further
References & further reading

Peer-reviewed journals & authoritative standards

  1. 01String (computer science)Wikipedia, 2026.
  2. 02The Python TutorialPython 3 documentation, 2026.
  3. 03Data typeWikipedia, 2026.
  4. 04Python (programming language)Wikipedia, 2026.
Related lessons
Recap
Arithmetic operators compute numbers, with / giving a float, // the whole count that fits, % the remainder, and ** powers; parentheses control order. Strings join with +, format cleanly with f-strings (and codes like :.2f), and clean up with methods like strip(), lower() and split(). Comparison operators (>, ==, != and friends) return booleans for decisions - and == asks while = assigns. Because text and numbers are distinct types, int(), float() and str() convert between them, which you need at every input and output edge.
Carry forward →

You can compute and format results, but so far your values are hard-coded. Next we let a script talk with a person and document itself - reading input, printing polished output, and writing comments that keep code readable.

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 →