Data Types in Python refer to the classification or categorization of data based on the type of value it holds. Python has several data types, which includes:
Integer data type in Python, includes all the whole numbers, both positive and negative, without a decimal point. For example, 2, -5, 0.
Python float data type includes all the numbers with a decimal point, including numbers with a fractional part. For example, 3.14159, -2.5, 5.0.
Python Boolean data type can have one of two values. True or False.
Python String data type (str) includes the sequences of characters enclosed in single or double quotes. For example, “hello”, ‘world’, “123”.
Python list data type includes an ordered sequences of values, which can be of any data type, enclosed in square brackets. For example, [1, 2, 3], [“apple”, “banana”, “cherry”].
Python tuple data type are similar to lists, but they are immutable (cannot be modified), and are enclosed in parentheses. For example, (1, 2, 3), (“apple”, “mango”, “cherry”).
Note:- Lists are enclosed in square brackets and tuples are enclosed in parentheses.
Python set data type is an unordered collection of unique items. Elements in set are separated with commas and are enclosed in curly braces {}. For example {“apple”, “mango”, “banana”}.
Python dict data type is used to store an unordered collections of key-value pairs, enclosed in curly braces. For example, {“name”: “John”, “age”: 30}.