Follow

Python Data Types

veriable store different type of data
Text Type: String
Numeric Types: integer, float, complex
Sequence Types: List, Tuple, Range
Mapping Type: Dictionaries
Set Types: Set
Boolen Type: bool
None Type: NoneType

who get data type of veriable or an object

you get data type of veriable or an object using type()function:
python automatically understand data type

Python Data Types

#integer data type
x=5
print(type(x))
#float data type
y=2.4
print(type(y))
#complex data type
z=6j
print(type(z))
#string data type
var="hallo world"
print(type(var))

Try it Yourself »

Output

<class 'Int'>
<class 'Float'>
<class 'complex'>
<class 'String'>

Example Data Type
x = "hallo world" string
x = 2 int
x = 3.0 float
x = 3j complex
x = ['hallo', 'hi', 'gm'] list
x = ('hallo', 'hi', 'gm') tuple
x = {'mango', 'banana', 'papaya'} set
x = {'name':'jack','age':22, 'hobby':'playing'} dict
x = range(6) range
x = False} bool
x = None none type

Try it Yourself »

1 comment:

Tell us how you like it.