Thermodynamics : Work Done by a Gas Suppose in a piston in which there is a gas, the gas exerts pressure P on surroundings, whereas the surrounding exerts a pressure $P[ext]$ on the gas.

In order for the gas to expand, P must be greater than P[ext]. So far I understand. Suppose initially that $P&gt;P[ext]$ and the gas expands until $ P=P[ext]$ This is what I don't understand is that when you calculate the work done by the gas, you use the external pressure and not the gas pressure. This makes no sense to me. After all, if you calculate the work done on something, you should use the force or pressure applied on that object, or not the other way around, correct? So why do we use external pressure instead of internal pressure when calculating the work done by the gas?
Assuming an adiabatic wall between gas and surroundings then the expansion of the gas will do work on the surroundings.  What is that work?  It is the pdV work using the external pressure acting against the piston from the surroundings.   You are asking why not use the pressure of the gas.  You could, but only if the process was reversible.  That is, the gas is at equilibrium throughout the expansion process.  

But what if the gas is not at equilibrium throughout the expansion?   The pressure may not be uniform inside the gas throughout the expansion.  If the gas is expanding irreversibly then the pressure just behind the piston will be lower than the other parts of the gas.   It's easier to calculate the work on the surroundings since you know the external pressure is uniformly applied.