Data types in Python
| Site: | Dr. B.R. Ambedkar Open University Online Learning Portal |
| Course: | Basics of Programming with Python |
| Book: | Data types in Python |
| Printed by: | Guest user |
| Date: | Saturday, 30 May 2026, 2:53 AM |
Description
This book resource provides the information like definition and various types of data types in Python.
Note : This is mandatory to complete. After completion, you can manually mark the activity as completed
1. Definition with examples
Data type is a classification that specifies which type of value a variable can hold. It defines the type of operations that can be performed on that variable and how those values are stored in memory. Data types are essential in programming because they help ensure the correctness and consistency of data manipulation.
Python has a dynamic typing system, which means that you don't need to explicitly declare the data type of a variable when you create it. Instead, Python infers the data type based on the value assigned to the variable.This image helps to acquire knowledge about various types of data types in python.

2. Types of Data types
There are various types of data types supported by Python. They are:
- Numeric data types
- Dictionary data types
- Boolean data types
- Set data types
- Sequence data type
The following sub chapters provides you the detailed information about all these data types. let's go through them.
2.1. Numeric Data types (Integer, float, complex)
1. Numeric Data Types:
Numeric data types are used to specify the number type that is stored in a variable.
Numeric data types are again categorized into three categories.
a. Integer
b. Float
c. Complex
a. Integers: this data type specifies the value that is stored in a variable is any integer number of any length.
Example: a=10, b=-20 etc.
a = 30
print("The type of a", type(a))
Output:
The type of a <class ‘int’>
b. Float: This data type specifies the value that is stored in a variable is a decimal number.
Example: 22.9, 2.7 etc
x=43.211
Print (“The type of x”, type(x))
Output:
The type of a <class ‘float’>
c. Complex Number: This data type is used to represent numbers in the format a+bi, where a & b are real numbers and ‘I or j’ is an imaginary unit. In python complex number are created using the syntax a+bj. Operations like addition, subtraction, multiplication, and division etc can also performed on complex numbers.
Example
a=3+6j
print(“The type of a”, type(a))
Output:
The type of a <class ‘complex’>
2.2. Dictionary Data type
Dictionary is a built-in data type used to store collections of data in a key-value pair format. Every key is associated with a value and key is unique.
Dictionaries can be created by curly braces ‘{ } ‘ and key-value pairs are separated by colon ‘:’ . Key- value pair can be any other data types.
Example: employee = {‘name’:’Battu’, ‘salary’:40000, ‘dept’:’CSE’, ‘id’:22243 }
Print(“The type of empleyee”, type(employee))
Output:
The type of employee <class ‘dictionary’>
2.3. Boolean Data type
It is also a built-in data type that can hold a value either True or False. Boolean values are used to make logical decisions and control flow of a program. Boolean values are also used to perform conditional operations.
Example:
a=True
print("The type of a", type(a))
Output:
The type of a <class ‘bool’>
2.4. Set data type
It is a built-in data type. Python set data type is like set in mathematics. Set is an unordered collection unique elements. It is used to store and manipulate collection of data without duplications.
We can create set using curly braces ‘{ }’ or ‘set( )’ constructor. Elements of set are separated by comma ‘,’.
Example:
Animals = {‘dog’,’cat’,’cow’,’tiger’,’elephant’}
Print(“The type of Animals”, type(Animals))
Output:
The type of Animals<class ‘set’>
2.5. Sequence data type
A sequence is an ordered collection of values. The sequence is a powerful, fundamental abstraction in computer science. Sequences are not instances of a particular built-in type or abstract data representation, but instead a collection of behaviors that are shared among several different types of data. That is, there are many kinds of sequences, but they all share common behavior. In particular,
Length. A sequence has a finite length. An empty sequence has length 0.
Element selection. A sequence has an element corresponding to any non-negative integer index less than its length, starting at 0 for the first element.
Python includes three main data types that are sequences. They are
- String
- List
- Tuple
"2.3 Sequences" by John DeNero is licensed under CC BY 3.0
3. Supplementary Material
Here is an URL of video that deals with data types. This may help you. please go through it.
"What are data types in Python" by DevForDev is licensed under CC BY-SA 3.0