Data Types in Python

In Python a variable can hold different types of values. Python provides various standard data types that define the storage method on each of them. The different data types in python are given below:
(i) Boolean
(ii) Numeric - Integer, Float, Complex
(iii) Dictionary
(iv) Set
(v) Sequence Type - String, List, Tuple

In Python, the data type is set when we assign a value to a variable. We can get the data type of a variable with the type() function.
a=True #Boolean
print("The type of a", type(a))
b=1 #Integer
print("The type of b", type(b))
c=1.0 #Float
print("The type of c", type(c))
d=5j #Complex
print("The type of d", type(d))
e={"Name":"Neoogy","Domain":"neoogy.com"} #Dictionary
print("The type of e", type(e))
f={"PHP","Python","Java"} #Set
print("The type of f", type(f))
g="Neoogy" #String
print("The type of g", type(g))
h=[1,2,3,4,5] #List
print("The type of h", type(h))
i=(6,7,8,9,10) #Tuple
print("The type of i", type(i))

Output will be
The type of a <class 'bool'>
The type of b <class 'int'>
The type of c <class 'float'>
The type of d <class 'complex'>
The type of e <class 'dict'>
The type of f <class 'set'>
The type of g <class 'str'>
The type of h <class 'list'>
The type of i <class 'tuple'>


0 Comments