Software Development Exam  >  Software Development Notes  >  Basics of Python  >  Python Data Types

Python Data Types | Basics of Python - Software Development PDF Download


Python is a versatile programming language known for its simplicity and flexibility. Understanding data types is crucial for effective programming in Python. In this article, we will explore the fundamental data types in Python, their characteristics, and provide examples to solidify your understanding.

Numeric Data Types

Numeric data types are used to represent numbers in Python. They include integers, floating-point numbers, and complex numbers.

Integers (int)

Integers represent whole numbers without any fractional component. They can be positive or negative. Here's an example:

x = 10

Output: <class 'int'>

Floating-Point Numbers (float)

Floating-point numbers represent real numbers with a fractional component. They are written with a decimal point or in scientific notation.

y = 3.14

Output: <class 'float'>

Complex Numbers (complex)

Complex numbers consist of a real and an imaginary part. They are written in the form a + bj, where a is the real part and b is the imaginary part. 


z = 2 + 3j

Output: <class 'complex'>

Sequence Data Types

Sequence data types are used to represent collections of items. They include strings, lists, and tuples.

Strings (str)

Strings are sequences of characters enclosed in single quotes ('') or double quotes (""). They are immutable, meaning they cannot be changed once created. 


message = "Hello, world!"

Output: <class 'str'>

Lists (list)

Lists are ordered collections of items enclosed in square brackets ([]). They can contain elements of different data types and are mutable. 


numbers = [1, 2, 3, 4, 5]

Output: <class 'list'>

Tuples (tuple)

Tuples are ordered collections of items enclosed in parentheses (()). They are similar to lists but are immutable. 


coordinates = (10, 20)

Output: <class 'tuple'>

Mapping Data Type

Mapping data types are used to store key-value pairs. They include dictionaries.

Dictionaries (dict)

Dictionaries are unordered collections of key-value pairs enclosed in curly braces ({}). Keys are unique, and each key is associated with a value. 


student = {"name": "John", "age": 20, "grade": "A"}

Output: <class 'dict'>

Set Data Type

Set data types are used to store a collection of unique elements. They are unordered and do not allow duplicate values.

Sets (set)

Sets are created by enclosing comma-separated elements inside curly braces ({}) or by using the set() function. 


fruits = {"apple", "banana", "orange"}

Output: <class 'set'>

Set operations such as union, intersection, and difference can be performed on sets to manipulate their contents.

Boolean Data Type

Boolean data type represents two values: True and False. It is commonly used for logical operations and comparisons.

Boolean (bool)

Booleans are either True or False. They are often the result of a comparison or logical operation. Example:

is_valid = True

Output: <class 'bool'>

None Type

None is a special data type in Python that represents the absence of a value or the absence of a return value.

result = None

Output: <class 'NoneType'>

Type Conversion

Python provides built-in functions to convert values from one data type to another. This process is known as type conversion or type casting.

# Example of type conversion
x = "10"
y = int(x)  # Convert x to an integer

Output: <class 'int'>

Type conversion is particularly useful when you need to perform operations or comparisons between different data types.


Understanding Python data types is essential for writing effective and robust code. In this article, we explored the fundamental data types in Python, including numeric types (int, float, complex), sequence types (str, list, tuple), mapping types (dict), set types (set), boolean type (bool), and None type. We also discussed type conversion, which allows you to convert values from one data type to another.
By having a solid understanding of these data types, you can write more expressive and efficient Python code to handle a wide range of tasks and solve complex problems.

The document Python Data Types | Basics of Python - Software Development is a part of the Software Development Course Basics of Python.
All you need of Software Development at this link: Software Development
49 videos|38 docs|18 tests
49 videos|38 docs|18 tests
Download as PDF
Explore Courses for Software Development exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Download the FREE EduRev App
Track your progress, build streaks, highlight & save important lessons and more!
Related Searches



mock tests for examination


Python Data Types | Basics of Python - Software Development


Previous Year Questions with Solutions




past year papers


Important questions


Python Data Types | Basics of Python - Software Development


Semester Notes




video lectures


practice quizzes




Viva Questions


Python Data Types | Basics of Python - Software Development


study material


shortcuts and tricks




Objective type Questions


Extra Questions


Sample Paper