Basics

Variables

Names are bound to values with assignment.

Assignment binds a name to a value. Once bound, the name can be used anywhere that value is needed.

Source

message = "hi"
print(message)

Output

hi
xINT42
A name is a label that points at an object. Assignment binds the label; the object exists independently.

Assignment can rebind the same name to a different value. The name is not permanently attached to the first object.

Source

message = "hello"
print(message)

Output

hello

Augmented assignment reads the current binding, computes an updated value, and stores the result back under the same name.

Source

count = 3
count += 1
print(count)

Output

4

Notes

See also

Run the complete example

Example code

Expected output

hi
hello
4

Execution time appears here after you run the example.