To solve this optimization problem, we first need to define the decision variables and the objective function. Let's denote the number of commercials purchased during cartoons as \(x\) and the number of commercials purchased during kids-movies as \(y\).

The objective is to minimize the total cost, which can be represented by the function: 
\[ \text{Minimize} \quad 5000x + 12000y \]

Given the constraints:
1. Each cartoon is seen by 2 million young boys and 1 million young girls.
2. Each kids-movie is seen by 4 million young boys and 6 million young girls.
3. The company wants their commercials to be seen by at least 30 million young boys and 40 million young girls.

We can formulate the constraints as follows:
- For young boys: \(2x + 4y \geq 30\)
- For young girls: \(x + 6y \geq 40\)

Also, since we cannot purchase a negative number of commercials, we have:
- \(x \geq 0\)
- \(y \geq 0\)

Now, let's translate this into Gurobi code in Python:

```python
from gurobipy import *

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

# Define the decision variables
x = m.addVar(vtype=GRB.CONTINUOUS, name="cartoon_commercials", lb=0)
y = m.addVar(vtype=GRB.CONTINUOUS, name="kids_movie_commercials", lb=0)

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

# Add constraints
m.addConstr(2*x + 4*y >= 30, "young_boys")
m.addConstr(x + 6*y >= 40, "young_girls")

# Optimize the model
m.optimize()

# Print the results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Number of cartoon commercials: {x.x}")
    print(f"Number of kids-movie commercials: {y.x}")
    print(f"Total cost: ${5000*x.x + 12000*y.x:.2f}")
else:
    print("No optimal solution found")

```