3  Basic Syntax

3.1 Variables and values

A variable is a name that refers to a value.

project_name = "Python Field Guide"
year = 2026
is_active = True

print(project_name, year, is_active)
Python Field Guide 2026 True

3.2 Basic types

values = {
    "text": "hello",
    "integer": 10,
    "decimal": 3.14,
    "boolean": True,
    "nothing": None,
}

for name, value in values.items():
    print(name, type(value).__name__)
text str
integer int
decimal float
boolean bool
nothing NoneType

3.3 String formatting

language = "Python"
units = 23

summary = f"This guide contains {units} units about {language}."
print(summary)
This guide contains 23 units about Python.

3.4 Things to remember

  • Python is case-sensitive.
  • Indentation is part of the syntax.
  • Use meaningful variable names.
  • = assigns a value; == compares values.