It is given that the ratio of hydrogen and oxygen by mass to form water is 1:8. Then, the mass of oxygen gas required to react completely with 1 g of hydrogen gas is 8 g. Therefore, the mass of oxygen gas required to react completely with 3 g of hydrogen gas is 8×3 g=24 g.