E-mail : support@tech2now.in

DataTypes in Python

Python has the following datatypes. Below is some example for each one.

# DataType str
x = "Hi Techies"
print("Type of x: ", type(x))
 
# DataType int
x = 100
print("Type of x: ", type(x))

 
# DataType float
x = 40.5
print("Type of x: ", type(x))

# DataType list
x = ["techno2", "for", "techno2"]
print("Type of x: ", type(x))

# DataType tuple
x = ("techno2", "for", "techno2")
print("Type of x: ", type(x))

# DataType range
x = range(33)
print("Type of x: ", type(x))

 
# DataType dict
x = {"name": "Anupam", "age": 24}
print("Type of x: ", type(x))

# DataType set
x = {"techno2", "for", "techno2"}
print("Type of x: ", type(x))

 
# DataType frozenset
x = frozenset({"techno2", "for", "techno2"})
print("Type of x: ", type(x))

 
# DataType complex
x = 3j
print("Type of x: ", type(x))

 
# DataType memoryview
x = memoryview(bytes(6))
print("Type of x: ", type(x))

 
# DataType NoneType
x = None
print("Type of x: ", type(x))


# DataType bool
x = True
print("Type of x: ", type(x))

 
# DataType bytes
x = b"techno2"
print("Type of x: ", type(x))

 
# DataType bytearray
x = bytearray(4)
print("Type of x: ", type(x))

Output:
Type of x:  <class 'str'>
Type of x:  <class 'int'>
Type of x:  <class 'float'>
Type of x:  <class 'list'>
Type of x:  <class 'tuple'>
Type of x:  <class 'range'>
Type of x:  <class 'dict'>
Type of x:  <class 'set'>
Type of x:  <class 'frozenset'>      
Type of x:  <class 'complex'>        
Type of x:  <class 'memoryview'>     
Type of x:  <class 'NoneType'>       
Type of x:  <class 'bool'>
Type of x:  <class 'bytes'>
Type of x:  <class 'bytearray'>     

GitHub Repository