Basics

Values

Python programs evaluate expressions into objects such as text, numbers, booleans, and None.

Start with several built-in values. Python does not require declarations before binding these names, and each value is still an object with a type.

Source

text = "python"
count = 3
ratio = 2.5
ready = True
missing = None

print(type(text).__name__)

Output

str
INT42STR"hi"LIST[1,2,3]DICT{k:v}
Every literal is an object with a type; the type carries the behaviour, not the variable name.

Methods and operators evaluate to new values. The original text, count, and ratio bindings remain ordinary objects you can reuse.

Source

print(text.upper())
print(count + 4)
print(ratio * 2)

Output

PYTHON
7
5.0

Boolean expressions combine facts, and None is checked by identity because it is a singleton absence marker.

Source

print(ready and count > 0)
print(missing is None)

Output

True
True

Notes

See also

Run the complete example

Example code

Expected output

str
PYTHON
7
5.0
True
True

Execution time appears here after you run the example.