Every program, no matter how big, is really just a pile of values being stored, changed and passed around. In Python, a variable is just a name attached to a value, and unlike some languages, you never have to tell Python ahead of time what type of value that name is going to hold.

Creating a variable

age = 25
name = "Maria"
price = 9.99
is_member = True

No int, no String keyword, no declaring anything up front. You just write the name, an equals sign, and the value, and Python figures out the rest. This is what people mean when they call Python "dynamically typed" — the type lives with the value, not with the variable name itself.

The types you'll meet on day one

  • int — whole numbers, like 25 or -3.
  • float — numbers with a decimal point, like 9.99.
  • str — text, wrapped in quotes, either single or double, Python doesn't mind which as long as you're consistent.
  • bool — just True or False, and yes, they are capitalised.

Working with strings

Strings come up constantly, so it's worth getting comfortable with them early. You can glue two strings together with a plus sign, but a much nicer way in modern Python is an f-string:

name = "Maria"
age = 25
print(f"{name} is {age} years old")

That little f right before the opening quote tells Python "look inside the curly braces and substitute real values." Once you start using f-strings you'll probably never go back to gluing strings together with plus signs — it's just so much easier to read.

Checking a variable's type

print(type(age))     # <class 'int'>
print(type(price))   # <class 'float'>

You won't use type() much in everyday code, but it's genuinely useful when you're debugging and something isn't behaving the way you expect — half the time the bug turns out to be a value that's a string when you assumed it was a number.

A gotcha worth knowing early

Dividing two integers in Python always hands you a float back, even if the division is exact:

result = 10 / 2
print(result)  # 5.0, not 5

If you actually want integer division that drops the remainder, use two slash characters instead of one: 10 // 2 gives you 5. Small detail, but it catches people off guard more often than you would think, usually the first time a "5" they expected shows up as "5.0" somewhere it matters.

What is next

Once single values feel comfortable, the natural next step is storing groups of them — lists, tuples and dictionaries — which is exactly what the next tutorial covers.