OmniTaught / Topics / Python for Humans

Py

For coders

Python for Humans

Code from zero, then check what AI writes for you.

Start this topic free See all topics

What this covers

Every lesson is short enough to finish in one sitting and ends with questions that make you use what you just read.

  1. What Code Actually IsA recipe the computer follows to the letter5 min
  2. Variables: Boxes with LabelsGiving names to values so you can use them later5 min
  3. Decisions: if, elif, elseTeaching your program to respond differently to different situations6 min
  4. Loops: Doing Things Many TimesWrite the step once, let the computer repeat it6 min
  5. Functions: Name a RecipePackage steps under a name so you can reuse them anywhere6 min
Show all 13 lessonsShow fewer lessons
  1. Lists and DictionariesOrdered collections and labeled collections, the two shapes of everyday data6 min
  2. Reading Code You Did Not WriteSkim it, narrate it, trace it6 min
  3. Test It Before You Trust ItKnown answers, edge cases, and print5 min
  4. The Ways AI Code LiesSeven failure patterns to hunt for6 min
  5. The Verification WorkflowA repeatable checklist for shipping with confidence6 min
  6. When It Breaks: Reading the ErrorA traceback is a help message wearing a scary costume9 min
  7. Text and FilesWhere the syntax finally does something useful9 min
  8. Python Timed Simulation: Set A30 items, 35 minutes, exam mode35 min

A whole lesson, start to finish

Not a sample and not a summary. This is all of lesson 2, exactly as it reads in the app.

Lesson 2 of 13 · about 5 min

Variables: Boxes with Labels

Giving names to values so you can use them later

A box with a label on it

A variable is a labeled box. The line age = 34 means take the value 34 and store it in a box labeled age. From then on, anywhere you write age, Python quietly swaps in 34. You already do this professionally: a client file labeled with a name, a folder labeled Q3 Grades. Label once, refer to it forever.

Careful

In Python, = is not the math equals sign. It never asks a question, it gives a command: store the thing on the right under the name on the left. Reading count = count + 1 as math looks impossible, reading it as 'take what is in count, add 1, put the result back in the box' makes perfect sense.

Boxes can be refilled. If you run x = 5 and later x = 8, the box labeled x now holds 8 and the 5 is gone. The label stays, the contents change, exactly like updating a client's session count each week.

Numbers versus text

Python treats 7 and "7" as different things. Without quotes it is a number you can do math with. With quotes it is a string, which is just the coding word for a piece of text. Strings can hold anything typeable: names, notes, emails. Adding two numbers gives a sum, but adding two strings glues them together, so "3" + "4" gives "34".

To weave a variable into a sentence, use an f-string: put an f before the opening quote and wrap the variable in curly braces. With name = "Ada", the line print(f"Hi {name}") shows Hi Ada. Think of it as a form letter where the braces mark the blank to fill in.

Key idea

Names are for humans. Python is equally happy with s or session_count, but future you, reading this code in three months, will thank you for the descriptive one.

Remember

Valid names use letters, numbers, and underscores, with no spaces, and cannot start with a digit. client_count works, 2clients and client count do not.

That is genuinely all a variable is: a name pointing at a value. Every impressive program you have ever used, from scheduling software to your phone's messages, is mostly thousands of these labeled boxes being filled, read, and updated.

Now answer the question that follows it

This is one of 8 questions on that lesson. Pick an answer and it will tell you.

In 'age = 34', what does the = sign do?

Terms you will own

Cards come back on a schedule built from how well you knew them last time, so the ones you keep missing show up more.

More in for coders

🤖AI-Assisted DevelopmentFor experienced developers making the shift from writing code to directing it

Start Python for Humans free

Every topic on the site is open during the beta. Nothing to install, and your progress follows you between devices.

Start learning free