Unit 1 · Fundamentals

Lesson · Unit 1 · 8 min read

What programs actually do, and how to translate an idea into Python.

Every program — from your phone's calculator to a 50M-line cloud platform — does the same three things. Once you see the shape, Python stops feeling magical and starts feeling like a hammer.

Section · 01

Every program does three things

A program reads something, does something with it, and produces a result. In that order. Input, process, output. That’s it. Once you internalize this, every script you read starts to make sense in the first 30 seconds.

# A 5-line weather alert program

temp_str = input("Current outdoor temp (°F): ")   # 1. INPUT
temp = float(temp_str)                            # 2a. PROCESS — convert
warning = "Bundle up." if temp < 35 else "OK."    # 2b. PROCESS — decide
print(f"Reading: {temp}°F — {warning}")           # 3. OUTPUT

Five lines, three responsibilities. The first reads from the keyboard. The next two transform that raw string into a number and then a decision. The last writes a result. You can grow this into a weather service that polls an API every 60 seconds and texts you when a storm hits, but the shape never changes.

Section · 02

An algorithm is the plan before the code

An algorithmis a fancy word for a list of steps that solves a problem. Algorithms aren’t Python. They’re English (or a whiteboard, or a sticky note). The mistake every beginner makes is starting to type before they know the steps.

Here’s the algorithm for the script above, written before any code:

1. Ask the user for the current temperature
2. Convert it from text to a number
3. If the number is below 35, set warning = "Bundle up"
   Otherwise, set warning = "OK"
4. Print the temperature and the warning

You can translate this line by line into Python. If you can’t write the steps in English, you can’t write them in Python. That’s usually the real problem when someone says they’re “stuck.”

Section · 03

The development loop

Once you start typing, you’re in a tight cycle for the rest of your career. Four steps:

1. Write a small change.
2. Run the code.
3. Read what happened — the output, or the error.
4. Decide the next change.

Beginners try to write the whole program first and run it once. It never works. Senior engineers write 3 lines, run it, write 3 more, run it. The loop gets faster the better you get, but it never disappears. When you hit an error, read the lastline of the traceback first — that’s usually where the actual problem is.

Section · 04

Why Python

It’s readable

Python uses indentation instead of curly braces, English-y keywords (if, not, in), and fewer symbols than most languages. A Python script reads almost like pseudocode. That’s a feature, not a coincidence — it was designed that way to be easy on humans.

It’s interpreted

You write a .py file, type python my_file.py, and it runs. No compile step, no build pipeline, no project file. This is why Python dominates data science, scripting, and prototyping — the loop above (write, run, read, decide) is fast.

Batteries included

Python ships with a huge standard library — modules for reading JSON, talking to HTTP, doing math, parsing dates, working with files. You’ll spend a lot of time learning what’s already built rather than building it yourself. That’s a good investment.

Section · 05

What to do next

Three things, in order:

1. Install Python 3 from python.org (or use a free online editor).
2. Type the temperature script above into a file called alert.py.
3. Run it with: python alert.py — then change the threshold and run it again.

You learn programming by typing programs, not by reading about them. The next lesson digs into the data types you just used — str, float, int — and the rules for naming variables. After that, the rest of Unit 1 is just filling in the toolbox.

Curriculum source

Lesson content is original to YorkSims. Topic structure aligns with Python for Everybody by Dr. Charles R. Severance (py4e.com), licensed under Creative Commons Attribution 3.0 Unported.