Question №2
Remaining:
What are the basic data types in Python?
Sample Answer
Show Answer by Default
Python provides several built-in data types:
Numeric types:
- int — integers of arbitrary precision: 42, -7, 1_000_000
- float — floating-point numbers: 3.14, -0.5, 1e10
- complex — complex numbers: 3+4j
Text type:
- str — character string: "Hello", 'Python'
Boolean type:
- bool — takes values True or False
Special type:
- NoneType — the single value None, meaning the absence of a value
Type conversion:
# Explicit type conversion x = int("42") # str → int y = float(42) # int → float z = str(3.14) # float → str w = bool(0) # int → bool (False) # Type checking print(type(x)) # <class 'int'>
