๐Ÿ
๐Ÿ Python Fundamentals (Hands-On) ยท PY-101 ยท Session 1 of 6

Variables and Values

Everything in a program is data, and variables are how you store and name it. Master this and the basic types, and you have the raw material of all code.

โฑ 8 min read๐Ÿ“… Updated 2026-07-27๐Ÿ“Š Tables, charts & examples

This course is where you actually learn Python by writing it - ideally typing every example and running it (a free online editor or the sandbox works fine). We start with the most fundamental idea in all of programming: storing data in named variables. Get comfortable with variables and the basic types, and you have the raw material everything else is built from.

Variables: naming your data

A variable is a name that points to a value. You create one with = and use the name whenever you want the value.

name = 'Ada'          # a variable named 'name' holding the text 'Ada'
age = 30
print(name)            # Ada
print(age + 1)         # 31
age = age + 1          # variables can change - now age is 31
๐ŸŽฏ
= means 'store', not 'equals'. In maths = states a fact; in code x = 5 is a command: 'put 5 into the box called x'. That's why age = age + 1 makes sense - it means 'take age, add 1, and store the result back in age'. Names should describe what they hold (total, not t).

The basic types

Values come in types. The four you'll use constantly:

TypeIsExample
intA whole number42, -7, 0
floatA decimal number3.14, -0.5
strText (a 'string')'hello', "Ada"
boolTrue or FalseTrue, False

The type decides what you can do: you can add numbers, join strings, and test bools. Mixing them wrongly (like adding a number to text) causes an error - which is normal and fixable.

Try it and see

  • Type and run every example - reading isn't enough; doing wires it in.
  • Experiment - change values, combine variables, print things.
  • Check a type with type(x) if you're unsure what something is.
  • Errors are feedback - read them; they usually tell you what's wrong.

๐Ÿงฉ Do it with LarzOS

Turn this lesson into action with the exact free tools and AI workflows for the job:

๐ŸŽฏ Key takeaways

  • A variable is a name pointing to a value; create it with = (which means 'store', not 'equals').
  • The core types: int (whole numbers), float (decimals), str (text), bool (True/False).
  • The type determines what operations make sense; mixing them wrongly gives a normal, fixable error.
  • Type and run every example - doing, not just reading, is how you actually learn.

Frequently asked

Why does age = age + 1 work? It looks like nonsense mathematically.

Because in programming = is an instruction to store, not a mathematical statement of equality. Read age = age + 1 as: 'calculate the right side (the current age plus 1), then store that result back into the variable age'. So if age was 30, the right side becomes 31, and age is updated to 31. It's an extremely common pattern (adding to a running total, counting, etc.). If the = symbol confuses you, mentally translate it to '<-' ('gets') - age <- age + 1 - which makes the 'store the new value' meaning obvious.

Do I need to declare a variable's type like in some other languages?

No - Python figures out the type from the value you assign, so you just write name = 'Ada' or age = 30 and Python knows one is a string and the other an int. This makes Python beginner-friendly. The type still matters (it decides what you can do with the value), and it can change if you reassign the variable to a different kind of value, but you never write the type out. If you're ever unsure what type a variable currently holds, type(variable) tells you.

Session 1 of 6 complete

Next up: Making Decisions with if

Continue to Session 2 โ†’

Related lessons

More in this course

Course home → · Browse all courses →