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

Lesson 1.4 · Python Fundamentals

Input, Output and Comments

Let a script talk with a person, present results cleanly, and document itself - and write your first genuinely interactive tool

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

A calculation you can only run by editing the code is a note to yourself. Add input, clear output and comments, and it becomes a tool someone else can use.

So far your scripts have had their numbers baked in - to try a different room you edited the code. This lesson closes Module 1 by making scripts interactive and readable: they ask a person for values, present results cleanly, and carry comments that explain what they do and why.

These three - input, output, comments - are what turn a private calculation into a small tool you could hand to a colleague. They are also where good habits start: clear output that a non-coder can read, and comments that mean you (or a teammate) can still understand the script in six months. We finish by building a real interactive estimator from the pieces you have gathered across the module.

input() ALWAYS returns text - convert at the door. Comment the WHY. Ask, compute, report.

print() - presenting output clearly

You have used print() since the first lesson; now meet its useful details. print() can take several values at once, separated by commas, and it puts a single space between them and moves to a new line at the end:

python
room = "Kitchen"
area = 12.5
print("Room:", room, "Area:", area)
# Room: Kitchen Area: 12.5

Two optional settings control that behaviour. sep sets what goes between the values (default a space), and end sets what goes at the end (default a newline):

python
print("A-101", "A-102", "A-103", sep=" | ")
# A-101 | A-102 | A-103
print("Loading", end="...")
print("done")
# Loading...done   (both on one line, because end was not a newline)

For anything with numbers in it, though, the f-string from the last lesson usually beats juggling commas - it gives you full control of spacing, wording and number formatting in one readable piece:

python
print(f"Room: {room:<10} Area: {area:>6.1f} sqm")
# Room: Kitchen    Area:   12.5 sqm

Here :<10 left-aligns the room name in a 10-character space and :>6.1f right-aligns the number in 6 characters with one decimal - the trick for printing tidy, column-aligned tables straight to the screen. You do not need every format code memorised; know that print() plus f-strings can make output as clean as you want, and reach for alignment codes when you are lining up a little report.

There is a second, quieter use of print() that will save you constantly: checking what your code is actually doing. When a script misbehaves, dropping a print() in the middle to show a value - print("area so far:", area) - reveals whether the numbers are what you assumed at that point. This throwaway 'print debugging' is the simplest tool for finding where reality diverged from your expectation, and even seasoned programmers reach for it before anything fancier. So print() wears two hats: the polished output a user reads, and the rough running commentary you sprinkle in while building and then delete once it works.

COMMENTS: NOTES FOR HUMANS# tile budget for the lobby floorarea = 24.5rate = 1450# 8 percent waste for cuts at edgescost = area * rate * 1.08print(cost)green = a commentstarts with #Python ignores itcompletely.white = real codePython runs it.Comments say WHY, not what. The future you who reopens this file will thank you.
Zoom
Comments are notes for humans that Python ignores. The green lines starting with # are skipped when the script runs; the white lines are real code that executes. Good comments explain why - here, what the waste factor is for - rather than restating what the code plainly does.

input() - reading what a person types

To ask a person for a value, use the `input()` function. You give it a prompt to show, and it waits for the person to type something and press enter, then hands you back what they typed:

python
name = input("Room name: ")
print("You entered:", name)

Run that and the script pauses, shows Room name: , and whatever you type becomes the value of name. Simple - but there is one rule you must never forget, and it is the single most common input() bug: `input()` always gives you a string. Even if the person types 12, you receive the text "12", not the number 12. So before you can calculate with it, you convert:

python
length_text = input("Wall length in m: ")  # a string like "6"
length = float(length_text)                # now a number: 6.0
# or, more compactly, wrap it in one line:
height = float(input("Wall height in m: "))
area = length * height
print(f"Wall area: {area:.2f} sqm")

That float(input(...)) pattern - ask, then immediately convert - is one you will write hundreds of times. Use int() when you want a whole number (a count of sockets), float() when a decimal makes sense (a length or rate). This is exactly the text-to-number conversion from the previous lesson, now with a clear reason to care: the outside world hands your program text, and you translate it at the door.

A few practical notes. You can ask for several values in a row, one input() per line, and the script simply pauses at each until the person answers - that is how the interactive tool at the end of this lesson gathers a whole set of dimensions. Write prompts that are clear and include the unit you expect: "Wall length in m: " tells the person both what to type and in what unit, heading off the classic mismatch where you assumed metres and they typed centimetres. And be aware that input() will accept anything, including nonsense - if someone types "wide" when you asked for a length, the float() will raise a ValueError and stop the script. For your own tools that is usually fine; gracefully surviving bad input is a Module 3 topic (try/except). For now, clear prompts and immediate conversion cover the vast majority of real use.

INPUT -> PROCESS -> OUTPUTINPUTinput("width? ")the person typesPROCESSfloat(w) * float(h)compute the areaOUTPUTprint(area)show the resultinput() always hands you text, so convert before you calculate. Then print() speaks the answer back.
Zoom
The shape of an interactive script: input() takes text a person types, you convert and process it into a result, and print() reports it back. Because input() always hands you a string, the convert step - float() or int() - is not optional; it is how the outside world's text becomes numbers you can calculate with.

Comments - notes that keep code readable

A comment is a note in your code for humans, which Python ignores entirely when running. Anything after a # on a line is a comment:

python
# tile budget for the lobby floor
area = 24.5
rate = 1450        # unit rate per square metre
cost = area * rate * 1.08   # 8 percent added for cutting waste
print(cost)

Python runs area = 24.5 and skips everything green after the #. Comments cost nothing and are worth an enormous amount, for one reason: code tells you _what_ it does; comments tell you _why_. The line cost = area * rate * 1.08 is clear enough about the multiplication, but only the comment explains that the 1.08 is a waste allowance - the piece of intent that is invisible in the maths and impossible to reconstruct later. Six weeks from now, that note is the difference between understanding your own script and staring at it.

The craft of commenting is knowing what not to write. A comment that just restates the code - area = 24.5 # set area to 24.5 - is noise; it adds nothing and rots as the code changes. Good comments capture the things code cannot say: why a number is what it is, where a magic figure came from, an assumption you made, or a warning about a tricky bit. Aim to explain reasoning, not mechanics. A short, honest comment above a chunk of code - # assumes rectangular rooms; splits L-shapes elsewhere - is one of the kindest things you can leave for the next person, who is very often you.

Comments have a second, humbler use while you work: switching code off without deleting it. Put a # in front of a line and Python skips it, so you can silence a print() you were using to check a value, or park a line you are unsure about, then restore it later by removing the #. Most editors do this to a whole selection with a keyboard shortcut (often Ctrl-/ or Cmd-/). This 'commenting out' is a everyday move when hunting a bug - disable half the script, see if the problem goes away, and narrow down where it lives - and it beats deleting code you might want back in a minute.

Writing readable code, not just working code

Working code and good code are not the same thing, and the gap is almost entirely readability - because you will read a script far more often than you write it. A handful of cheap habits, applied from now, make everything downstream easier.

Name things meaningfully (from Lesson 1.2): wall_area, not w. Use blank lines to separate a script into logical paragraphs - inputs together, then the calculation, then the output - so the shape is visible at a glance. Comment the why, not the what. And keep each line doing one clear thing rather than cramming a page of logic into a dense one-liner. Compare:

python
print(float(input("L: "))*float(input("W: ")))   # works, but opaque

with:

python
# floor area from length and width the user enters
length = float(input("Length in m: "))
width  = float(input("Width in m: "))
area   = length * width
print(f"Floor area: {area:.2f} sqm")

Both compute the same number. The second you can read, check, reuse and hand to someone else; the first you will not understand next week. This is not perfectionism - your scripts can stay small and rough (that is the point of scripting) - it is the small discipline that keeps rough scripts usable. As the code you write grows past a few lines, readability is what stops it collapsing into a tangle, and it is the habit AI assistants and teammates both depend on to help you.

Putting it together - your first interactive tool

Everything in Module 1 now combines into a small tool that asks, computes and reports - the shape of countless useful scripts. Here is an interactive paint estimator that a colleague with no coding knowledge could run:

python
# Simple paint estimator - asks for a wall, reports litres and cost
print("--- Paint Estimator ---")

# inputs (convert text from input() into numbers straight away)
length = float(input("Wall length in m: "))
height = float(input("Wall height in m: "))
rate   = float(input("Paint price per litre: "))

# assumptions
coverage = 10   # sqm covered by one litre, one coat
coats    = 2    # standard two coats

# process
area   = length * height
litres = area * coats / coverage
cost   = litres * rate

# output
print(f"Wall area : {area:.1f} sqm")
print(f"Paint     : {litres:.1f} litres ({coats} coats)")
print(f"Est. cost : {cost:,.0f}")

Run it and it holds a small conversation, then prints a clean three-line report. Read its structure, because it is the template for almost everything ahead: a header, inputs converted at the door, named assumptions with comments explaining them, a process block of calculation, and a formatted output block. It is interactive, readable, and genuinely useful - a real tool you built from nothing but the pieces of this one module. That arc, from print("hello") in Lesson 1.1 to a working estimator here, is the whole promise of the course in miniature: small, clear instructions, combined, become leverage.

It is worth pausing on how far you have come in one module. You can install and run Python; store values in named variables of the right type; compute with arithmetic, build text with f-strings, compare values and convert between text and numbers; and now take input, present clean output, and document your reasoning. Put together, those are enough to write a genuinely useful single-run tool - and thousands of real design scripts are exactly that: ask, compute, report. What this estimator still lacks is the ability to decide (charge differently for a wet area) and to repeat (run over every room in a project, not one at a time). Those two powers - decisions and loops - are the whole of Module 2, and they are where a script stops being a fancy calculator and starts being the labour-saving engine the first lesson promised.

INPUT -> PROCESS -> OUTPUTINPUTinput("width? ")the person typesPROCESSfloat(w) * float(h)compute the areaOUTPUTprint(area)show the resultinput() always hands you text, so convert before you calculate. Then print() speaks the answer back.
Zoom
The shape of an interactive script: input() takes text a person types, you convert and process it into a result, and print() reports it back. Because input() always hands you a string, the convert step - float() or int() - is not optional; it is how the outside world's text becomes numbers you can calculate with.
Functions & practices in this lesson

print()

Display values; sep and end control separators and line endings

For number-heavy output, an f-string usually reads better than juggling commas.

input()

Read a line the user types; returns it as a string

Always gives text - wrap in float() or int() before you calculate. The classic beginner trap.

comment (#)

A human note Python ignores when running

Explain why, not what. Records intent - waste factors, sources, assumptions - that code cannot say.

readable code

Clear names, blank-line paragraphs, one idea per line

You read code more than you write it; small habits keep rough scripts usable and easy for AI and teammates to help with.

format spec

Codes inside f-string braces like :.1f, :,, :<10

Round, align and separate numbers for tidy, column-aligned output without manual spacing.

Hands-on workshop

Workshop - build a shareable interactive estimator

Turn a calculation you actually do into a small interactive tool a non-coder could run: it asks for inputs, converts them, computes, and prints a clean, commented report. This is Module 1's capstone.

Python 3 and an editor. No libraries needed. A willing non-coder to test it is a bonus.

Given & goal
Goal: a commented, interactive estimator someone else could use
Inputs: pick a real task - paint, tiles, flooring, or cost per room
Time: ~35 minutes
  1. 1Choose one everyday quantity task. In estimator.py, print a short header line naming the tool.
  2. 2Ask for each input with input(), wrapping every one in float() or int() immediately so you store numbers, not text.
  3. 3Add named assumption variables (waste factor, coverage, rate) each with a short # comment explaining why the value is what it is.
  4. 4Compute the result in a clear block with meaningful names, then print a two-or-three-line report using f-strings with format codes so numbers are rounded and aligned.
  5. 5Run it, then hand the file (or the running prompt) to someone who does not code and watch them use it. Fix anything they found unclear - in the prompts, the output wording, or a comment.

You’ll walk away with
An `estimator.py` that holds a short conversation, converts all input at the door, documents its assumptions with why-comments, and prints a cleanly formatted report - usable by someone who has never seen the code.

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

Interactive scripts turn a recurring calculation into a shareable studio tool. An estimator that asks for a few inputs and prints a clean summary can live on a shared drive and be run by anyone, not just its author - no editing code required. The input/convert/report pattern here is the same one your later Rhino and Revit scripts use to take parameters and report results, so the habit scales straight into design software.

For the interior designerScripts for data, schedules & layouts

A well-commented, interactive estimator is exactly the kind of quick tool that pays for itself on every project. Paint, tile, wallpaper, curtain or upholstery quantities all follow the same ask-compute-report shape you built here. Clean f-string output means the result is presentable straight away, and comments recording your assumptions (waste factors, coverage rates) keep the numbers defensible when a client or contractor asks how you got them.

For the studentA hireable computational skill

Readable, commented, interactive code is what a reviewer or employer actually looks for. Anyone can make code that runs; the mark of someone worth hiring is code another person can read - clear names, sensible comments, tidy output. Build these habits now on tiny scripts and they will be automatic by the time your projects are large. This interactive-tool pattern is also the backbone of the more advanced Academy courses in generative and computational design.

Misconception check

Comments are a waste of time - if the code is written clearly, it explains itself, so commenting is just extra typing.

Half true, and the half that is wrong causes real pain. Clear code with good names genuinely removes the need to comment on what each line does - area = length * width needs no explanation, and a comment restating it is noise. But no amount of clean code can express why: why the waste factor is 8 percent and not 10, where a magic constant came from, what assumption a formula rests on, or why you did something the non-obvious way. That intent lives only in your head at the moment of writing and is gone weeks later. Comments are how you capture it. So the right rule is not 'comment everything' or 'comment nothing' - it is comment the why, not the what. A few honest lines recording reasoning are worth far more than their typing cost the first time you, or a colleague, reopen the file.
Try it

Do it yourself

Build and run each - the interactive ones only teach you by being typed into.

  1. 1Why does age = input("Age: ") then age * 2 not double the number? Fix it.
  2. 2Use print() with sep to print three drawing numbers separated by | on one line.
  3. 3Write a comment that is genuinely useful and one that is noise, for the line total = qty * rate * 1.05.
  4. 4Rewrite print(int(input('n: '))*50) as three clear, commented lines.
  5. 5Build a two-input interactive script that asks for length and width and prints the area to one decimal place.
Take this with you

The one line to carry out

Input, output and comments turn a private calculation into a tool: input() asks a person (always returning text you must convert), print() and f-strings present results cleanly, and comments record the why that code cannot - together making scripts interactive and readable.
Take it further
References & further reading

Peer-reviewed journals & authoritative standards

  1. 01The Python TutorialPython 3 documentation, 2026.
  2. 02Computer programmingWikipedia, 2026.
  3. 03Software documentationWikipedia, 2026.
  4. 04Welcome to Python.orgPython Software Foundation, 2026.
Related lessons
Recap
print() displays values, with sep and end for fine control and f-string format codes for aligned, rounded output. input() reads what a person types but always returns a string, so you convert with float() or int() before calculating - the ask-then-convert pattern you will use constantly. Comments (after #) are ignored by Python and exist for humans; write them to explain why, not what. Readable code - clear names, blank-line paragraphs, one idea per line - is what keeps rough scripts usable, and combining all of this yields a small interactive tool: ask, compute, report.
Carry forward →

You can now write a complete interactive script - the end of Module 1's fundamentals. Next, in Module 2, your code gains the power to make decisions and repeat itself: conditionals and booleans, then loops - where scripting's real leverage begins.

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 →