
Data Types in Python | CBSE Class 11 | CBSE Class11
Dear Class 11th STUDENTS,
Welcome to this tutorial of Data types in python from your CBSE class 11 of Computer Science Syllabus.
In this tutorial, we shall be learning our chapter-3 from Unit 2: Programming and Computational Thinking (PCT-1) as CBSE BOARD suggested to learn about different types of data types in python to complete this section.
After going through this tutorial, you will be able to understand the following topics from your latest syllabus 2025-26.
Unit 2: Programming and Computational Thinking (PCT-1)
Chapter: Knowledge of data types in python:
- Number (integer, floating point, complex)
- Boolean
- Sequence (string, list, tuple)
- None
- Mapping(dictionary)
- Mutable and immutable data types.
I advice you to check the latest syllabus given by CBSE Board at its Official website: www.cbseacademic.nic.in
Also, in this tutorial we will covers all necessary topics/concepts required to complete your exams preparations in CBSE classes 11th.
Also, you can Sign Up our free Computer Science Courses for classes 11th and 12th.
NOTE:
- We are also giving some important Questions & Answers for better understanding as well as preparation for your examinations.
- You may also download PDF file of this tutorial from our SHOP for free.
- For your ease and more understanding, we are also giving the video explanation class of each and every topic individually, so that you may clear your topics and get success in your examinations.
Introduction to data types in Python
In any language, there are some fundamentals you need to know before you can write even the most elementary programs. In this tutorial, we are going to introduce some such fundamentals: data types, variables, operators and expression in Python.
Python provides a predefined set of data types for handling the data it use. Data can be stored in any of these data types. This chapter is going to discuss various types of data that you can store in Python. Of course, a program also needs a means to identify stored data.
So, this tutorial we shall also talk about mutable and immutable variables in Python.
Data can be of many types for example, character, integer, real, string etc. Anything enclosed in quotes represents string data in Python. Numbers without fractions represent integer data. Numbers with fractions represent real data and True and false represent Boolean data. Since the data to be dealt with are of many types, a programming language must provide ways and facilities to handle all types of data.
Before you learn how you can process different types of data in Python, let us discuss various data- types supported in Python. In this discussion of data types, you “II be able to know Python’s capabilities to handle a specific type of data, such as the memory space it allocates to hold a certain type of data and the range of values supported for a data type etc.
Built-in Core Data Types in Python
In python programming, data can be of many types for example
- Integer: Numbers without fractions represent integer data (Like 1 or 2 or 3).
- Real: Numbers with fractions represent real data (like 1.2 or 3.5 or 7.4).
- Complex: A complex number is always in the form of A+Bi. Where I is the imaginary number (equal to the square root of -1).
- Boolean: True and false represent Boolean data (Like 0 or 1).
- String: Anything enclosed in quotes represents a string (Like “Python” or ‘Python’) data in Python.
- List: A list in python represents a list of comma-separated value of any datatype between square brackets like: L=[1,2,3,4,5].
- Tuple: Tuples are represented as group of commas – separated values of any data type within parentheses, like: P = (1,2,3,4,5).
- Dictionary: The dictionary is an unordered set of comma-separated key value pairs, within [], like: D = [“a” : 1, “b” : 2, “c” : 3].
Since the data to be dealt with are of many types, a programming language must provide ways and facilities to handle all types of data and no doubt, python programming language is doing a very good work in this area.
Before learning, how can you process different types of data in Python, let’s start learning of these Built-in Core Data types of python programming and get a very good understanding to work with python programming language.
In this discussion of data types, you “II be able to know Python’s capabilities to handle a specific type of data, such as the memory space it allocates to hold a certain type of data and the range of values supported for a data type etc.
From a beginner’s point of view, here we are dividing our discussion in the following types.
- Numeric (Numbers, Integer, Float, Complex)
- String
- List
- Tuple
- Dictionary
Numeric data types in Python
As it is clear by the name the number data types are used to store numeric values in Python. The numbers in Python have the following core data types:
- Integers – (signed & Unsigned)
- Floating – point Numbers
- Complex Numbers
Integers:
Integers are whole numbers such as 5, 39, 19117, O etc. They have no fractional parts. Integers are represented in Python by numeric values with no decimal point. Integers can be positive or negative, e.g., + 12, – 15, 3000 (missing + or – symbol means it is positive number).
Floating point numbers
A number having fractional part is a floating-point number. For example, 3.14159 is a floating-point number. The decimal point signals that it is a floating -point number, not an integer. The number 12 is an integer, but 12.0 is a floating-point number. Recall that fractional numbers can be written in two forms:
- Fractional Form (Normal Decimal Notation) e.g., 3500.75, 0.00005, 147.9101 etc.
- Exponent Notation e.g., 3.50075EO3, 0.53-04, 1. 479101EO2 etc.
Floating point variables represent real numbers, which are used for measurable quantities like distance, area, temperature etc. and typically have a fractional part. Floating -point numbers have two advantages over integers:
- They can represent values between the integers:
- They can represent a much greater range of values. But floating-point numbers suffer from one disadvantage also:
- Floating-point operations are usually slower than integer operations.
In Python, floating point numbers represent machine-level double precision floating point numbers2 (15digit precision). The range of these numbers is limited by underlying machine architecture subject to available (virtual) memory.
Complex Numbers:
Python represents complex numbers in the form A + B j. That is, to represent imaginary number, python uses j (or j) in place of traditional i. so in python I. so in python, . Consider the following examples where “a” and b are storing two complex in python:
a = 0 + 3. 1 j
b = 1.5 + 2 j
The above complex number “a” has real component as 0 and imaginary component as 3.1; in complex number b, the real part is 1.5 and imaginary part is 2. When you display complex numbers, python displays complex numbers in parentheses when they have a nonzero real part as shown in following examples
Unlike python’ s other numeric types, complex numbers are a composite quantity made of two parts: the real part and the imaginary part , both of which are represented internally as float values ( floating point numbers).
You can retrieve the two components using attribute references. For a complex number z:
- real gives the real part.
- imag gives the imaginary part as a float, not as a complex value.
Boolean Data Types:
These represent the truth values false and true. The Boolean types is a subtype of plain integers, and Boolean values false and true behave like the values O and 1, respectively. To get the Boolean equivalent of O or 1, you can type bool (O) Bool (1), Python will return False or Ture respectively. However, when you convert Boolean values False and True to a string, the strings “False” or “True” are returned, respectively. The str () function converts a value to string.
However, when you convert boolean values TRUE and FALSE to a string, the strings TRUE and FALSE are returned, respectively. The str() function converts a value to string.
Boolean Operators:
Boolean operators are keywords and symbols, such as AND or NOT, which facilitate you to expand or narrow your search parameters while using a database or search engine. When you search using these operators, it is known as a Boolean search.
You can use Boolean operators such as AND, OR, and NOT alongside keywords to create a Boolean string that will refine your search to find the most relevant results and sources.
Common boolean operations are –
- Boolean AND operator.
- Boolean OR operator.
- Boolean NOT operator.
- Boolean equivalent (==) operator.
- Boolean not equivalent(!=) operator.
The lists and tuples are python’s compound data types. we have taken them together in one section because they are basically the same type with one difference. lists can be changed /modified (i.e., mutable) but tuples cannot be changed or modified (i.e., immutable). let us talk about these two types one by one.
String Data Types:
You already know about strings (as data) in Python. In this section, we shall be talking about Python’s data type strings. A string data type lets you hold string data, i.e., any number of valid characters into a set of quotation marks.
In Python, each character stored in a string is a Unicode character. Or in other words, all strings in Python 3.x are sequences of pure Unicode characters. Unicode is a system designed to represent every character from every language. A string can hold any type of known characters i.e., letters, numbers, and special characters, of any known scripted language.
Following are all legal strings in Python:
“abcd”, “1234”, ‘$%^&, 2222’, “ŠÆËS”, “222222”, 2222
List Data Types:
A list in python represents a list of comma-separated value of any datatype between square brackets e.g., following are some lists:
1,2,3,4,5]
[‘a’,’e’,’I’,’o’,’u’]
[Qissba, 102, 79.5]
Like any other value, you can assign a list to a variable.
Example
>>> a= [1,2,3,4,5] #statement 1
>>> a [1,2,3,4,5]
>>> print (a) [1,2,3,4,5]
To change first value in a list namely given above, you may write
>> a[0] = 10 #change 1st item – consider statement 1 above
>>> a [10,2,3,4,5]
To change 3rd item, you may write
>> a [2] = 30 #change 3rd item
>>> a [10,2,30,4,5]
You guessed it right; the value internally are numbered from (zero) onwards i.e., first item of the list is internally numbered as zero, second item of the list as 1,3rd item as 2 and so on.
Tuple Data Types:
You can think of tuples (pronounced as tu-pp-le, rhyming with couple) as those lists which cannot be changed i.e., are not modifiable. Tuples are represented as group of commas – separated values of any data type within parentheses, e.g., following are some tuples:
P = (1,2,3,4,5)
q = (2,4,6,8,)
r = (‘a’,’e’,’I’,’o’,’u’)
h = (7,8,9, ‘A’,’B’,’C’)
Dictionary Data Types:
Dictionary data types is another feature in python’s hat. The dictionary is an unordered set of comma-separated key : value pairs, within [ ], with the requirement that within a dictionary, no two keys can be the same (i.e., there are unique keys within a dictionary). For instance, following are some dictionaries:
persondict = {
“name”: “qissba”,
“age”: “09”,
“class”: 4
}
Another example of dictionary:
Adddict = {
“city”: “delhi”,
“pin”: “110034”,
“country”: india
}
None Data Types
“None” is a special data type that represents the absence of a value or a null value. It’s used to signify that a variable doesn’t have a value assigned to it or that a function hasn’t returned any value.
Mutable and immutable Data types
The python data objects can be broadly categorized into two –mutable and immutable types, in simple words changeable or modifiable and non-modifiable types.
Immutable Data Types
The immutable types are those that can never change their value in place.in python, the following types are immutable: integers, floating point numbers, Booleans, strings, tuples.
Let us understand the concept of immutable types.in Order to understand this, consider the code below:
Sample code Example
P=5
q=p
r=5
: #will give 5, 5, 5
P=10
r=7
q=r
After reading the above code, you can say that values of integer variables p, q, r could be changed effortlessly. Since p, q, rare integer types, you may think that integer types can change values. But hold: It is not the case. Let’s see how.
You already know that in python, variable –names are just the references to value-objects i.e., data values. The variable –names do not store values themselves i.e., they are not storages containers. Recall section 6.5.1 where we briefly talked about it.
Now consider the Sample code example given above. internally, how python processes these assignments is explained in Figure given below Carefully go through given figure on the next page and then read the following lines.
So, although it appears that the value of variable p /q /r is changing; values are not changing “in place” the fact is that the variable –name s are instead made to refer to new immutable integer object. (Changing in place means modifying the same value in same memory location).
Initially these three-statement s are executed:
You can check /confirm it yourself using id (). the id () returns the memory address to which a variable is referencing.
Please note, memory addresses depend on your operating system and will vary in different sessions
When the next set of statements execute, i.e.
P = 10
R = 7
q = r
Then these variable names are made to point to different integer objects. That is, now their memory addresses that they reference will change. The original memory address of P that was having value 5 will be the same with the same value i.e.,5 but p will no longer reference it. Same is for other variables.
https://qissba.com/wp-content/uploads/2025/06/memory-concept-of-immutable-data-types-cbse-class-11.jpg
let us check their ids
Now if you assign 5 to any variable. Let us see what happens
Thus. It is clear that variable names are stored as references to a value –object. Each time you change the value, the variable’s reference memory address changes variable (of certain types) is NOT LIKE storage containers i.e., with fixed memory address where value changes every time Hence, they are IMMUTABLE.
The objects of following value types are immutable in python:
- Integer floating point number
- Booleans strings
- tuples
Mutable Data Types
The mutable types are those whose values can be changed in place. Only three types are mutable in python. these are: lists, dictionaries and sets.
To change a member of a list. You may write:
Chk = [2, 4, 6]
Chk [1] =40
It will make the list namely chk as [2,40.6]