Informatics Practices

Python Data Types | Mutable and Immutable Data Types | Complete Notes | CBSE Class 11 Informatics Practices (2026–27)

Class 11 · Informatics Practices

Python Data Types | Mutable and Immutable Data Types

Every value stored in Python belongs to a particular data type. A data type tells Python what kind of data is being stored and what operations can be performed on it. Choosing the correct data type makes programs efficient, readable, and less prone to errors.


What is a Data Type?

Definition

A data type specifies the type of value stored in a variable and determines the operations that can be performed on that value.

Example

```python age = 16 name = "Rahul" marks = 92.5 passed = True ``` Here, - `16` is an integer. - `"Rahul"` is a string. - `92.5` is a floating-point number. - `True` is a Boolean value.

Built-in Data Types in Python

Category Data Type Example
Numeric int 25
Numeric float 85.75
Numeric complex 3+4j
Boolean bool True
Text str "Python"
Sequence list [10,20,30]
Mapping dict {"A":90}

Note: Although list and dictionary are discussed later in the syllabus, they are also built-in Python data types.


Integer (int)

The int data type stores whole numbers without a decimal point.

Examples

```python roll_no = 25 temperature = -8 population = 1400000000 ```

Floating-Point (float)

The float data type stores numbers containing a decimal point.

Examples

```python percentage = 87.5 height = 165.2 price = 99.99 ```

Complex Numbers (complex)

Python supports complex numbers, which contain a real part and an imaginary part represented using j.

Examples

```python z1 = 4+5j z2 = 2-3j ```

Boolean (bool)

A Boolean value represents one of two possible values: True or False.

Examples

```python result = True eligible = False ``` Boolean values are commonly used in decision-making statements.

String (str)

A string is a sequence of characters enclosed in single quotes, double quotes, or triple quotes.

Examples

```python name = "Rahul" city = 'Jaipur' message = """Welcome to Python""" ```

Checking the Data Type

The type() function returns the data type of a value or variable.

Program

```python a = 25 b = 15.8 c = "Python" d = True print(type(a)) print(type(b)) print(type(c)) print(type(d)) ``` Output ```text ```

Mutable and Immutable Data Types

Important Concept

Python data types are classified as mutable or immutable depending on whether their values can be changed after creation.


Mutable Data Types

A mutable object can be modified after it is created.

Examples

  • List
  • Dictionary
  • Set

Program

```python marks = [70,80,90] marks[1] = 85 print(marks) ``` Output ```text [70, 85, 90] ``` The list changes without creating a new object.

Immutable Data Types

An immutable object cannot be modified after it is created. Any modification creates a new object.

Examples

  • int
  • float
  • bool
  • str
  • tuple

Program

```python name = "Python" name = name + " Programming" print(name) ``` Output ```text Python Programming ``` The original string is not modified. Instead, a new string object is created.

Mutable vs Immutable Data Types

Feature Mutable Immutable
Can be modified Yes No
Memory Same object can be updated New object is created
Examples List, Dictionary int, float, bool, str, tuple

Real-Life Examples

Situation Data Type
Student Roll Number int
Percentage float
Student Name str
Pass/Fail Status bool
Marks of Subjects list
Student Details dict

Common Errors

Mistake Correct Concept
Using quotes around numbers. "25" is a string, not an integer.
Writing true or false in lowercase. Python uses True and False.
Assuming strings are mutable. Strings are immutable.
Thinking lists cannot be modified. Lists are mutable.
Confusing int and float. Integers have no decimal point; floats do.

Quick Revision

Concept Remember
int Whole numbers
float Decimal numbers
complex Numbers with imaginary part
bool True or False
str Sequence of characters
Mutable Can be modified
Immutable Cannot be modified

CBSE Exam Tips

  • Know the difference between int, float, complex, bool, and str.
  • Remember which data types are mutable and which are immutable.
  • Practice using the type() function.
  • Do not confuse strings containing digits with numeric values.
  • Remember that Boolean values are written as True and False.

Summary

Python provides several built-in data types for storing different kinds of information. Numeric data types include integers, floating-point numbers, and complex numbers, while Boolean values represent logical conditions and strings store text. Python also classifies data types as mutable or immutable based on whether their values can be changed after creation. A clear understanding of data types is essential for writing efficient and error-free Python programs.