0% found this document useful (0 votes)
2 views

Predefined Objects in Python

The lesson plan outlines predefined objects and data types in Python, including numeric types (int, float, complex), sequence types (str, list, tuple), mapping types (dict), set types (set, frozenset), boolean type (bool), and NoneType. It also explains the concepts of mutable and immutable objects, highlighting that mutable objects can be modified after creation while immutable objects cannot. Examples of mutable objects include lists and dictionaries, whereas integers and strings are examples of immutable objects.

Uploaded by

kp.kashish2007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Predefined Objects in Python

The lesson plan outlines predefined objects and data types in Python, including numeric types (int, float, complex), sequence types (str, list, tuple), mapping types (dict), set types (set, frozenset), boolean type (bool), and NoneType. It also explains the concepts of mutable and immutable objects, highlighting that mutable objects can be modified after creation while immutable objects cannot. Examples of mutable objects include lists and dictionaries, whereas integers and strings are examples of immutable objects.

Uploaded by

kp.kashish2007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like