Data types in Python
2. Types of Data types
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’>