Going back to the circuit we started with, you can see that the electrical power is calculated by multiplying together the current in the bulb and the voltage across it. In general:
powerwatt = voltagevolt × currentampere
Now, the voltage across bulb is 12 volt and the current in bulb is 2 ampere, so
power of bulb = 12 volt × 2 ampere
and the power of the bulb is calculated as 24 watt.
Note that the power calculated here includes the total energy shifted by the bulb through lighting and through heating. The energy shifted by the electrical working pathway does not all end up being shifted by the lighting pathway. The bulb is not as efficient as we'd like. More on this can be found in the SPT: Energy topic.
An example to explore
Here is a simple loop, where you can choose the battery and choose the bulb, so setting the resistance of that bulb. These choices have consequences for the current in the loop and the power dissipated by the bulb and switched by the battery.
The code is quite intelligible–the physics is only two lines:
voltageresistance = current
power = current × voltage
The remaining code is all concerned with the display.