Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Question 5 of 10 · Python Basics & Syntax
Interview question

What are Python's built-in data types? Python के built-in data types क्या हैं?

Answer
CategoryTypes
Numericint, float, complex
Sequencestr, list, tuple, range
Mappingdict
Setset, frozenset
Booleanbool
Binarybytes, bytearray, memoryview
None typeNoneType
print(type(5))          # <class 'int'>
print(type(5.0))        # <class 'float'>
print(type('text'))     # <class 'str'>
print(type([1, 2]))     # <class 'list'>
print(type((1, 2)))     # <class 'tuple'>
print(type({'a': 1}))   # <class 'dict'>
print(type({1, 2}))     # <class 'set'>
print(type(True))       # <class 'bool'>
print(type(None))       # <class 'NoneType'>

# Checking types
x = 5
print(isinstance(x, int))  # True - preferred over type() == comparison
CategoryTypes
Numericint, float, complex
Sequencestr, list, tuple, range
Mappingdict
Setset, frozenset
Booleanbool
None typeNoneType
print(type(5))          # int
print(type('text'))     # str
print(type([1, 2]))     # list
print(type((1, 2)))     # tuple
print(type({'a': 1}))   # dict
print(type({1, 2}))     # set
print(type(None))       # NoneType

x = 5
print(isinstance(x, int))  # True - preferred तरीका

Was this answer clear?