Lesson Plan:
Predefined Objects
in Python
There are several predefined objects and data types in Python. These objects are readily available for use
without the need for any additional imports. Here are some of the most common predefined objects in Python
Numeric Types
int: Integer numbers (e.g., 42, -10)
float: Floating-point numbers (e.g., 3.14, -0.5)
complex: Complex numbers with real and imaginary parts (e.g., 2 + 3j)
Sequence Types
str: Strings of characters (e.g., "hello", 'world')
list: Mutable sequences of elements (e.g., [1, 2, 3])
tuple: Immutable sequences of elements (e.g., (1, 2, 3))
Mapping Types
dict: Mutable collections of key-value pairs (e.g., {'a': 1, 'b': 2})
Set Types
set: Mutable collections of unique elements (e.g., {1, 2, 3})
frozenset: Immutable collections of unique elements (e.g., frozenset({1, 2, 3}))
Boolean Type
bool: Boolean values representing True or False
NoneType
None: A special object representing the absence of a value or a null value.
In the above you came across these two terminologies: Mutable and Immutable. Let’s understand what they
really mean:
Mutable Immutable
Objects whose state can be modified Objects whose state cannot be
after creation are called mutable modified after creation are called
objects. immutable objects.
Lists, dictionaries, sets, and user-
xamples include integers, floating-
defined classes (unless explicitly
E
point numbers, strings, tuples, and
designed to be immutable) are
frozensets.
examples of mutable objects.
M utable objects can be altered in Immutable objects cannot be changed
place; that is, you can change their once they are created. Any operation
contents without creating a new that appears to modify an immutable
object. object actually creates a new object.
Data Science With Generative AI Course