What are the different ways to assign values in Python?
There are several ways to assign values in Python.
- Assign a value using the equal sign (=), for example: x = 10.
- Multiple assignments, such as: x and y are assigned the values 10 and 20, respectively.
- Incremental assignment, for example: x += 5 (equivalent to x = x + 5)
- Unpacking assignment, for example: x, y = (10, 20)
- Chain assignment, for example: x = y = 10.
- Enhance assignment, for example: x, y = y, x (swapping variable values)
These are common assignment methods used in Python, you can choose the appropriate assignment method based on specific situations.