Datatypes in a language used to store the data in a variable.
This tutorial explains various native built-in data types supported by Python.
Python provides the following data types
Datatype | Description |
---|---|
str | String Text content |
int, float, complex | Numeric data |
list,tuple,range | Sequential data storage |
dict | Python hashmap or dictionary |
set,frozenset | set data structure, does not allow duplicates |
bool | boolean values true or false for conditional expression |
NoneType | Not assigned with any datatype |
bytes, byte array,memoryview | Binary data storage |
A variable is created using data type or literal.
For example, the Number of integers can be created as given below.
number=11 or
number= int(11)
Here is an example Python data type example.
varint=11
print(type(varint))
varfloat=11.11
print(type(varfloat))
varcomplex=11j
print(type(varcomplex))
str="welcome"
print(type(str))
list = ["one", "two", "three"]
print(type(list))
tuple = ("one", "two", "three")
print(type(tuple))
rangevar = range(10);
print(type(rangevar))
employee = {"id":1,"name":"john"};
print(type(employee))
set = {"one", "two", "three"}
print(type(set))
frozenset = frozenset({"one", "two", "three"})
print(type(frozenset))
boolean = True
print(type(boolean))
bytes = b"welcome"
print(type(bytes))
bytearray = bytearray(11)
print(type(bytearray))
nonetype = None
print(type(nonetype))
Output:
<class 'int'>
<class 'float'>
<class 'complex'>
<class 'str'>
<class 'list'>
<class 'tuple'>
<class 'range'>
<class 'dict'>
<class 'set'>
<class 'frozenset'>
<class 'bool'>
<class 'bytes'>
<class 'bytearray'>
<class 'NoneType'>