Imagine a gas in a cylinder with a piston on top, and a bunch of small weights sitting on top of the piston. The system is initially at equilibrium. Now imagine three scenarios:
You suddenly remove a large fraction of the weights from the top of the piston, and then let the system re-equilibrate.
You remove a series of smaller (finite) weights from the piston one at a time, and, after you remove each weight, you allow the system to re-equilibrate. You keep removing weights until the gas attains the same final expansion as scenario 1.
You remove extremely small weights from the piston one at a time (the weights are really differential in size, so this is continuous, and, after your remove each differential weight, you allow the system to re-equilibrate. You need removing differential weights until the gas attains the same final expansion as in scenarios 1 and 2.
Scenario 1 is irreversible. Scenario 2 is regarded as quasi static, but irreversible; if the small weights were infinitesimal in size, this scenario would be reversible. Scenario 3 is reversible.
In all three scenarios, the work is equal to the externally remaining weight per unit area integrated over the volume change (assuming the cylinder and piston are immersed in a vacuum). In scenario 1, this is equal to the weight remaining on the piston times the total volume change. In scenario 2, the work in each step of the expansion is equal to the weight pre unit area remaining on the piston after each small weight is removed, times the volume change in that step; the total work is equal to the sum of the incremental amounts of work. In scenario 3, the weight is being removed differentially, and the work is equal to the weight per unit area remaining on the piston integrated over the differential volume changes; in this scenario, the weight at each increment is also virtually identical to the gas pressure calculated from the ideal gas law times the area of the piston; so, in this case, the work is equal to the gas pressure calculated from the ideal gas law, integrated over the volume change