Assignment operators are used to assign values to variables. In Python, assignment operators provide a way to assign values to variables in various ways, including shorthand operations for common tasks.

## 1. Basic Assignment Operator

The basic assignment operator is `=`

, which assigns a value to a variable:

```
# Basic assignment
x = 10
y = 5
```

## 2. Compound Assignment Operators

Compound assignment operators combine an arithmetic operation with assignment. They provide a shorthand way to update the value of a variable.

### 2.1. `+=`

(Addition Assignment)

Increments the value of a variable by a specified amount:

```
# Addition assignment
x = 10
x += 5 # Equivalent to x = x + 5
print(x) # Output: 15
```

### 2.2. `-=`

(Subtraction Assignment)

Decrements the value of a variable by a specified amount:

```
# Subtraction assignment
x = 10
x -= 3 # Equivalent to x = x - 3
print(x) # Output: 7
```

### 2.3. `*=`

(Multiplication Assignment)

Multiplies the value of a variable by a specified amount:

```
# Multiplication assignment
x = 4
x *= 3 # Equivalent to x = x * 3
print(x) # Output: 12
```

### 2.4. `/=`

(Division Assignment)

Divides the value of a variable by a specified amount:

```
# Division assignment
x = 20
x /= 4 # Equivalent to x = x / 4
print(x) # Output: 5.0
```

### 2.5. `%=`

(Modulus Assignment)

Computes the remainder of division and assigns it to the variable:

```
# Modulus assignment
x = 10
x %= 3 # Equivalent to x = x % 3
print(x) # Output: 1
```

### 2.6. `//=`

(Floor Division Assignment)

Performs floor division and assigns the result to the variable:

```
# Floor division assignment
x = 17
x //= 5 # Equivalent to x = x // 5
print(x) # Output: 3
```

### 2.7. `**=`

(Exponentiation Assignment)

Raises the value of a variable to a specified power:

```
# Exponentiation assignment
x = 2
x **= 3 # Equivalent to x = x ** 3
print(x) # Output: 8
```

## 3. Practical Examples

Here are some practical examples of using assignment operators:

### 3.1. Calculating the Total Price with Discount

```
# Calculate total price with discount
price = 100
discount = 10
# Apply discount
price -= discount
print("Price after discount:", price) # Output: Price after discount: 90
```

### 3.2. Adjusting Speed in a Simulation

```
# Adjust speed in a simulation
speed = 50
acceleration = 5
# Increase speed
speed += acceleration
print("New speed:", speed) # Output: New speed: 55
```

## 4. Conclusion

Assignment operators in Python are essential for performing arithmetic operations and updating variable values efficiently. They simplify code and make it more readable by combining operations with assignment.