I approach these expansion problems like so: The gas and the surroundings(piston+outside) are at the same pressure at first. We heat the gas. The pressure rises inside the syringe a bit. The gas expands so the pressure remains constant. Then I use P(the constant pressure of the gas) *dV. What I want to confirm is my reasoning on using this equation. It was derived assuming P(internal) = constant. But it does change momentarily. Is the reason we ignore it in the "a bit" nature?
Also for compression, the force exerted on the gas by surroundings (piston+outside) is taken as the force the gas exerts on the piston. Is this Newton's third law?