Skip to content
Home » Python Native Data Types

Python Native Data Types

Here is a clear, complete, and exam-oriented explanation of Python Native Data Types, perfect for BCA/MCA/B.Tech students.


Python Native Data Types

Python is a dynamically typed language, which means you do not need to declare data types explicitly.
Python automatically identifies the data type based on the value stored.

Python provides several built-in (native) data types that form the core of the language.

These data types are:

  1. Numeric Types
  2. Sequence Types
  3. Set Types
  4. Mapping Types
  5. Boolean Type
  6. None Type

Let’s discuss each in detail.


1. Numeric Data Types

Numeric types represent numbers.

a) int (Integer)

Stores whole numbers (positive, negative, or zero).

Example:

x = 10
y = -5

b) float (Floating Point)

Stores decimal numbers.

Example:

pi = 3.14
height = 5.7

c) complex

Stores complex numbers (a + bj).

Example:

z = 2 + 3j

2. Sequence Data Types

Sequence types store ordered collections.


a) string (str)

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

Example:

name = "Python"

Strings are immutable.


b) list

Ordered, mutable (changeable) collection.

Example:

numbers = [10, 20, 30]
numbers[1] = 25

c) tuple

Ordered but immutable.

Example:

days = ("Mon", "Tue", "Wed")

d) range

Represents a sequence of numbers.

Example:

r = range(1, 10)

3. Set Data Types

Sets store unordered, unique items.


a) set

Mutable, unordered collection of unique elements.

Example:

s = {1, 2, 3, 3}  # duplicates removed

b) frozenset

Immutable version of set.

Example:

fs = frozenset([1, 2, 3])

4. Mapping Data Type

a) dict (Dictionary)

Stores key-value pairs.

Example:

student = {"name": "John", "age": 20}
  • Keys must be unique
  • Values can be of any type

5. Boolean Data Type

bool

Represents truth values:

  • True
  • False

Example:

a = True
b = (10 > 5)   # True

6. None Type

None

Represents absence of a value or null value.

Example:

x = None

Summary of Python Native Data Types

CategoryData TypeDescription
NumericintWhole numbers
floatDecimal numbers
complexComplex numbers
SequencestrString
listMutable ordered collection
tupleImmutable ordered collection
rangeNumber sequence
SetsetMutable unique elements
frozensetImmutable unique elements
MappingdictKey-value pairs
BooleanboolTrue/False
NoneNoneTypeNull value

Type Checking

To check the data type:

x = 10
print(type(x))

Output:

<class 'int'>

Examples of All Data Types

a = 10                 # int
b = 10.5               # float
c = 3 + 4j             # complex
s = "Hello"            # str
lst = [1, 2, 3]        # list
tup = (1, 2, 3)        # tuple
r = range(5)           # range
st = {1, 2, 3}         # set
fs = frozenset([1, 2]) # frozenset
d = {"name": "Tom"}    # dict
flag = True            # bool
nothing = None         # NoneType