Data types are used to define a type of variable. 1) Numeric 2) String 3) List 4) Tuple 5) Dictionary
Data
Types
•
Data types are used to define a type of variable.
•
In python there are five types of data type that are used commonly and those
are ‒

Fig. 1.5.1 Data types
in python
Python
numeric data type is used to hold numeric values like;
■
int ‒ Holds signed integers of non‒limited length.
■
long ‒ Holds long integers.
■
float ‒ Holds floating precision numbers and it's accurate upto 15 decimal
places.
■
complex ‒ Holds complex numbers.
In python we need not to declare data type
while declaring a variable like C or C++. We
can
simply just assign values in a variable. But if we want to see what type of
numerical value it is holding right now, we can use type(). For example ‒

■
String is a collection of characters.
■
In python, we can use single quote, double quote or triple quote to define a
string.
■
We can use two operators along with the string one is + and another is *.
■
The operator is used to concatenate the two strings. While *operator is used repetition
operation. Following execution
illustrates it‒
In [5] :
str1 = "My"
str2 = "Phython"
print(str1)
print(str2)
My
Phython

■
It is similar to arrays in C or C++ but it can simultaneously hold different
types of data in a list.
■
It is basically an ordered sequence of some data written using square
brackets([]) and commas(,)
■ For example –
In [8]: #List of only integers
a = [10,20,30,40,50]
print(a)
[10, 20, 30, 40, 50]
In [9]: #List of only strings
b = [ 'Sun', 'Mon', 'Tue', 'wed']
print(b)
['Sun', 'Mon', 'Tue', 'Wed']
In [10]:
#List of both integers and string
c = [11, 'Red', 'Green',2,3, 'Blue']
print(c)
[11, 'Red', 'Green', 2, 3, 'Blue']

■
Tuple is a collection of elements and it is similar to the list. But the items
of the tuple are separated by comma and the elements are enclosed in ()
parenthesis.
■
Tuples are immutable or read‒only. That means we can not modify the size of the
tuple or we cannot change the value of items of the tuple.
■
Here are examples of tuples
In [1]: #Tuple of only integers
a = (10,20,30,40,50)
print(a)
(10, 20, 30, 40, 50)
In [2]: #Tuple of both integers
and strings
b = ('one',1,2, 'two',
'three',3)
print(b)
('one', 1, 2, 'two', 'three', 3)

We
can display specific elements of a tuple using the index. For instance ‒
In [3]: print(b[3])
two

■
Dictionary is a collection of elements in the form of key:value pair.
■
The elements of dictionary are present in the curly brackets.
■
For example ‒
In [4]:
a = {1: 'Red',2: 'Blue',3: 'Green'}
print(a)
{1: 'Red', 2: 'Blue', 3: 'Green'}

There
are two types of boolean values ‒ true or false.
The
boolean expression can be represented using the operator. For example ‒
3=
=3
True
3=
=5
False
We
can also check the data type of True
and False with the help of type
function.
type(True)
<class 'bool'>
type(False)
<class 'bool'>
Some
of the valid boolean expressions are:
True
True
5= =4
False
3+2= =5
True
Python for Data Science: Chapter 1: Basics of Python : Tag: Computer Programming, Python, Data Science : - Data Types in python
Python for Data Science
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation
English Essentials II
EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Tamils and Technology தமிழர்களும் தொழில்நுட்பமும்
UC25H02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Linear Algebra
MA25C02 2nd Semester | 2025 Regulation
Applied Physics (CSIE) II
PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Digital Principles and Computer Organization
CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electrical and Electronics Engineering
EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Python for Data Science
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Re-Engineering for Innovation
ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Python for Data Science - Laboratory
AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation