0Pricing
Python Academy · Lesson

Variables and Assignment

Understand how variables work in Python and how to assign values.

Variables and Assignment is a free Python Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Welcome to Variables

In Python, a variable is a named container that stores a value. You create one simply by assigning a value with =.

Your First Variable

Write: name = 'Alice' This stores the string 'Alice' under the label 'name'. Python infers the type automatically.
name = 'Alice'
print(name)

Assignment Mechanics

The = sign is NOT equality — it means 'store the right-hand value into the left-hand name'. The value on the right is evaluated first.

Multiple Assignment

Python allows: a, b, c = 1, 2, 3 This unpacks values in one line. You can also do: x = y = 0 to assign the same value to multiple names.
a, b, c = 1, 2, 3
print(a, b, c)

Variable Naming Rules

Names must start with a letter or underscore, contain only letters/digits/underscores, and are case-sensitive. Use snake_case for readability.

Re-assigning Variables

Variables are not fixed. x = 5 then x = x + 1 makes x equal to 6. Python simply points the name to a new object.
x = 5
x = x + 1
print(x)

Augmented Assignment

Shorthand operators: x += 3 means x = x + 3. Similarly -= *= /= //= %= **= all work the same way.

Checking a Variable's Type

Use type() to inspect what kind of object a variable holds: type(42) returns . This is useful when debugging.
x = 3.14
print(type(x))

Constants by Convention

Python has no true constants, but ALL_CAPS names signal to other developers: 'don't change this'. Example: MAX_SIZE = 100.

Deleting a Variable

del x removes the name from the current scope. Accessing it afterwards raises NameError. Use del to free references you no longer need.

Quick Check

What keyword is used to remove a variable from scope in Python?

Recap

Variables are names bound to objects via =. Use snake_case, augmented assignment operators, and ALL_CAPS for constants. del removes a name from scope.

Next Steps

You now understand variable assignment in Python. Up next: numeric and boolean types to see what kinds of values you can store.

Frequently asked questions

Is the “Variables and Assignment” lesson free?

Yes — the full text of “Variables and Assignment” is free to read here on the web, and the Python Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python Academy course, upgrade to CoddyKit PRO.

What will I learn in “Variables and Assignment”?

Understand how variables work in Python and how to assign values. You practise Python Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Python Academy?

No prior experience is required. Python Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Variables and Assignment” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Python Academy lesson?

Yes. Every Python Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Variables and Assignment
  2. Numeric and Boolean Types
  3. Strings and Type Conversion
  4. Reading User Input
← Back to Python Academy