Python Data types is classification of data according to it’s type so that compiler can recognize the type of data and process it further.
Python supports several built-in data types that are used to represent different kinds of values in a program. Here are some of the most common data types in Python:
Numeric types :
Integers (int), floating-point numbers (float), and complex numbers (complex).
Boolean type :
True and False values (bool).
Sequence types :
Lists (list), tuples (tuple), and range objects (range).
Text type :
Strings (str).
Set types :
Sets (set) and frozensets (frozenset).
Mapping types :
Dictionaries (dict).
In addition to these built-in types, Python also supports several other types through modules or libraries, such as date time for date and time values, and numpy for numeric arrays.
In app development data types are a crucial so as to classify the data according to the type.
There are multiple data types out of which let us see the below in detailed
Numeric :
A numeric data type is used to represent numerical values. There are 4 types under numeric
- Integer
- Float
- Complex
- Boolean
Integer :
Represents whole numbers, such as 1, 2, 3, -4, -5, and so on. In Python, the integer data type is represented using the ‘int’ keyword.
Float :
Represents decimal numbers, such as 3.14, 2.5, -1.2, and so on. In Python, the float data type is represented using the ‘float’ keyword.
Complex :
Represents complex numbers with a real and imaginary part. In Python, the complex data type is represented using the ‘complex’ keyword, for example, 3 + 4j.
Boolean :
Boolean data types are used extensively in programming, especially in conditional statements and loops.
Python Data types Video Tutorial :
Go through the below tutorial for complete understanding of python data types.
Consider variable
a = 10
Now let us try to know the type of variable a
type(a) <class 'int'>
Here we can clearly find out the type of the variable to be integer.
a = 5.0 type(a) <class 'float'>
Now let us see a example of complex number which is a combination of number and a imaginary value.
a = 2 + 3j
Here j is imaginary, now try to find the type
type(a) <class 'complex'>
Boolean type variable
a = True type(a) <class 'bool'>
a= 1<3 type(a) <class 'bool'>
List :
In our previous tutorials we have clearly gone through the implementation of list in python programming you may find the link
a = [ 1 ,2, 3, 4 ] type(a) <class 'list'>
Set :
In our previous tutorials we have clearly gone through the implementation of set in python programming you may find the link
a = { 1, 2, 3, 4 } type(a) <class 'set'>
Tuple :
In our previous tutorials we have clearly gone through the implementation of tuple in python programming you may find the link
a = { 1, 2, 3, 4 } type(a) <class 'tuple'>
Range :
In our previous tutorials we have clearly gone through the implementation of tuple in python programming you may find the link
a = ( 0, 10 ) type(a) <class 'range'>
Dictionary :
In our previous tutorials we have clearly gone through the implementation of dictionary in python programming you may find the link
a = { "name" : "abhi", "age" : 25 } type(a) <class 'dict'>
String :
In our previous tutorials we have clearly gone through the implementation of string in python programming you may find the link
a = "abhi" type(a) <class 'str'>
If you have any query’s in this tutorial on python data types do let us know in the comment section below.If you like this tutorial do like and share us for more interesting updates..