data type
data type
DATA TYPE
Python Data types are the classification or
categorization of data items.
It represents the kind of value that tells
what operations can be performed on a
particular data.
Since everything is an object in Python
programming, Python data types are
classes and variables are instances
(objects) of these classes.
1. Numeric Data Types in Python
The numeric data type in Python
represents the data that has a numeric
value. A numeric value can be an integer,
a floating number, or even a complex
number.
Integers – This value is represented by int
class. It contains positive or negative
whole numbers (without fractions or
decimals). In Python, there is no limit to
how long an integer value can be.
Float – This value is represented by the
float class. It is a real number with a
floating-point representation. It is
specified by a decimal point.
Optionally, the character e or E followed
by a positive or negative integer may be
appended to specify scientific notation.
Complex Numbers – A complex number is
represented by a complex class. It is
specified as (real part) + (imaginary
part)j . For example – :2+3j
practical:-
a=5
print("Type of a: ", type(a))
b = 5.0
print("\nType of b: ", type(b))
c = 2 + 4j
print("\nType of c: ", type(c))