Most gases are colourless, so we identify them with simple chemical tests. Each test gives a result that only one of the four gases produces.
Oxygen relights a glowing splint. Blow out a burning wooden splint so that the end only glows, then put it in the gas. If it bursts back into flame, the gas is oxygen. Hydrogen is tested with a lit splint. The gas burns rapidly in air and makes a squeaky pop.
Carbon dioxide is tested by bubbling it through limewater. Limewater is a clear solution of calcium hydroxide, and it turns cloudy (milky) when carbon dioxide is passed through it. Chlorine is a pale green, poisonous gas with a sharp smell, so it must only be used in a fume cupboard. It is tested with damp blue litmus paper. The paper turns red briefly and is then bleached white.