Description: Integers are whole numbers without a decimal point. They can be positive or negative.
Mutability: Immutable (static).
Memory Consumption: Low.
Use Case: Storing counts or indices in a program.
an_integer = 10
Description: Floats represent real numbers and include a decimal point or exponent notation.
Mutability: Immutable (static).
Memory Consumption: Moderate.
Use Case: Representing fractional numbers or scientific calculations.
a_float = 3.14
Description: Complex numbers have a real and imaginary part.
Mutability: Immutable (static).
Memory Consumption: Moderate.
Use Case: Mathematical computations involving square roots of negative numbers or wave physics.
a_complex = 3 + 4j
Description: Booleans represent truth values, either True or False.
Mutability: Immutable (static).
Memory Consumption: Very low.
Use Case: Controlling program flow with conditional statements.
a_boolean = True
Description: Strings represent sequences of characters enclosed in quotes.
Strings represent sequences of characters enclosed in quotes.
Mutability: Immutable (static).
Immutable (static).
Memory Consumption: Depends on string length.
Depends on string length.
Use Case: Storing and manipulating textual data.
Storing and manipulating textual data.
a_string = "Hello, World!"
Description: Lists are ordered and mutable collections of items.
Mutability: Mutable (dynamic).
Memory Consumption: Depends on the number of elements.
Use Case: Storing multiple items in a single variable.
a_list = [1, 2, 3]
Description: Tuples are ordered and immutable collections of items.
Mutability: Immutable (static).
Memory Consumption: Low.
Use Case: Representing fixed collections of items.
a_tuple = (1, 2, 3)
Description: Dictionaries are key-value pairs of elements.
Dictionaries are key-value pairs of elements.
Mutability: Mutable (dynamic).
Mutable (dynamic).
Memory Consumption: Moderate to high.
Moderate to high.
Use Case: Storing data with associated keys for fast retrieval.
Storing data with associated keys for fast retrieval.
a_dict = {"brand": "Ford", "model": "Mustang", "year": 1964}
Description: Sets are unordered collections of unique elements.
Sets are unordered collections of unique elements.
Mutability: Mutable (dynamic).
Mutable (dynamic).
Memory Consumption: Moderate to high.
Moderate to high.
a_set = {1, 2, 3}
Use Case: Removing duplicates or testing membership of elements.
Removing duplicates or testing membership of elements.
Description: Frozensets are immutable versions of sets.
Frozensets are immutable versions of sets.
Mutability: Immutable (static).
Immutable (static).
Memory Consumption: Moderate.
Moderate.
a_frozenset = frozenset({1, 2, 3})
Use Case: Using sets as keys in dictionaries.
Using sets as keys in dictionaries.
Description: None represents the absence of a value or a null value.
None represents the absence of a value or a null value.
Mutability: Immutable (static).
Immutable (static).
Memory Consumption: Very low.
Very low.
a_none = None
Use Case: Initializing variables or denoting missing values.
Initializing variables or denoting missing values.