To solve this optimization problem, we first need to define the decision variables and the objective function. Let's denote the number of sour drops as \(x\) and the number of sour belts as \(y\). The objective is to minimize the total cost, which can be represented as \(0.5x + 0.4y\), given that each sour drop costs $0.50 and each sour belt costs $0.40.

The constraints are as follows:
1. The mixture must contain at least 30 units of sourness: \(2x + 4y \geq 30\).
2. The mixture must contain at least 40 units of flavoring: \(4x + 3y \geq 40\).
3. The mixture can contain at most 5 sour belts: \(y \leq 5\).

We also need to ensure that \(x\) and \(y\) are non-negative since they represent quantities of items.

Now, let's translate these constraints and the objective function into Gurobi code in Python:

```python
from gurobipy import *

# Create a model
m = Model("Candy_Mixture")

# Define the decision variables
x = m.addVar(vtype=GRB.CONTINUOUS, name="sour_drops")
y = m.addVar(vtype=GRB.CONTINUOUS, name="sour_belts")

# Set the objective function
m.setObjective(0.5*x + 0.4*y, GRB.MINIMIZE)

# Add constraints
m.addConstr(2*x + 4*y >= 30, "sourness_constraint")
m.addConstr(4*x + 3*y >= 40, "flavoring_constraint")
m.addConstr(y <= 5, "belt_limit")

# Optimize the model
m.optimize()

# Print the solution
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Sour Drops: {x.x}")
    print(f"Sour Belts: {y.x}")
    print(f"Total Cost: {m.objVal}")
else:
    print("No optimal solution found")
```