Python Data Types
Python Data Types
Python supports several built-in data types. Here's an overview of some of the most
commonly used data types in Python:
1. Numeric Types:
int: Integer numbers, e.g., 5, -3, 1000.
float: Floating-point numbers, e.g., 3.14, -0.001, 2.0.
complex: Complex numbers, e.g., 2 + 3j, -1 - 2j.
2. Sequence Types:
str: String, a sequence of characters, e.g., "hello", 'world'.
list: Ordered collection of items, mutable, e.g., [1, 2, 3], ['a', 'b', 'c'].
tuple: Ordered collection of items, immutable, e.g., (1, 2, 3), ('a', 'b', 'c').
3. Mapping Type:
dict: Collection of key-value pairs, e.g., {'name': 'John', 'age': 30}.
4. Set Types:
set: Unordered collection of unique items, mutable, e.g., {1, 2, 3}.
frozenset: Unordered collection of unique items, immutable, e.g.,
frozenset({1, 2, 3}).
5. Boolean Type:
bool: Represents Boolean values True and False.
6. None Type:
None: Represents the absence of a value or a null value.
These data types can be used to store different kinds of data and perform various
operations on them. Python is dynamically typed, meaning you don't need to
explicitly declare the data type of a variable; it's inferred based on the value assigned
to it.