Data Types & Variables
Python - A Quick Start for existing Programers
2 min read
Published Sep 16 2025, updated Sep 30 2025
Guide Sections
Guide Comments
In Python, variables do not have their types declared and are automatically assigned types based on the contents at run time.
Variables should be declared using lower case, snake case, eg. my_variable
. Variable names are case sensitive, so My_Variable
is considered different to my_variable
.
There is no concept of constants in Python. Standard practice is to use capitalised variables for constants as a naming convention, however, these are still variables so can be changed. eg. MY_CONSTANT
.
Basic data types
NoneType
: represents Nothing, or No Value:
int
: integer values:
No minimum or maximum number, only restricted by memory available.
float
: floating point numbers (decimals):
Smallest number 2.2250738585072014e-308
, largest number 1.7976931348623157e+308
, Anything beyond that becomes inf
(infinity).
complex
: complex numbers:
A complex number has two parts:
- a real part (like an ordinary number)
- an imaginary part (multiplied by
j
in Python, which represents √-1)
where
a
= real part (float or int)b
= imaginary part (float or int)j
= imaginary unit
You write j
(not i
, as in math) to denote the imaginary unit:
Minimum and maximums are the same as for float for each part.
bool
: boolean (True
or False
):
Text data type
str
: string (sequence of Unicode characters), wrapped in single or double quotes:
No maximum length, only restricted by memory available.
Multi value data types
list
: ordered, mutable collection, wrapped in square brackets:
tuple
: ordered, immutable collection, wrapped in standard brackets:
set
: unordered collection of unique elements, wrapped in curly brackets:
dict
: dictionary of key-value pairs:
bytes
: immutable sequence of bytes:
bytearray
: mutable sequence of bytes:
Casting one data type to another
Each data type has a function that can be called to cast data from one type to another:
Checking a variables type
The built-in type()
function returns the type (class) of an object:
You can use the type()
function for a direct comparison:
Note: This checks for an exact match, not subclasses.
Using isinstance()
is safer and more flexible, because it works with inheritance:
You can use issubclass()
to check if a class is derived from another class: