Data types in Python specify the kind of data that variables can hold and how it is stored. Python has various data types that include numbers (integers, floats), booleans, strings, and more complex types like lists, tuples, dictionaries, and sets.
Integers (int), floating point numbers (float), and complex numbers (complex).
x = 5 # int y = 3.14 # float z = 2j # complex
Represents true or false and is used in conditional expressions.
x = True # bool
Used to represent text data.
x = "Hello, World!" # str
Ordered and mutable collection of items.
x = [1, 2.2, 'python'] # list
Ordered and immutable collection of items.
x = (1, 2.2, 'python') # tuple
Unordered collection of key-value pairs.
x = {'key': 'value'} # dictUnordered collection of unique items.
x = {1, 2.2, 'python'} # setPython allows you to convert from one type to another using the int(), float(), str(), and similar functions.
x = 10 # int y = str(x) # now y is '10'