The chemistry
In electrolysis, positive ions move towards the negative cathode and negative ions towards the positive anode. The power supply moves electrons through the external circuit; ions carry charge through the electrolyte.
A molten simple ionic compound contains its positive and negative ions, without water. The metal forms at the cathode and the non-metal at the anode. Molten lead(II) bromide, for example, gives lead and bromine.
An aqueous solution also contains ions from water. At the cathode, hydrogen forms if the metal is more reactive than hydrogen. Copper is less reactive, so a copper salt solution deposits copper. For these inert-electrode GCSE examples, anions other than halides give oxygen at the anode, while chloride or bromide can give the corresponding halogen under suitable conditions.
Do not ignore the electrodes. Copper sulfate solution with inert electrodes produces copper and oxygen; using copper electrodes makes the anode dissolve, which is a different experiment. This exercise always uses inert electrodes.
Higher tier: ions gain electrons at the cathode (reduction), and ions lose electrons at the anode (oxidation). Half equations must balance both atoms and electrical charge. In aqueous solutions, equivalent ways of writing hydrogen and oxygen half equations are accepted by the answer checker.
Worked example
Molten NaCl: Na⁺ + e⁻ → Na at the cathode, and 2Cl⁻ → Cl₂ + 2e⁻ at the anode.
Concentrated NaCl(aq): hydrogen forms instead of sodium. One valid cathode half equation is 2H⁺ + 2e⁻ → H₂. Chlorine forms at the anode.
CuSO₄(aq) using inert electrodes: copper forms at the cathode; oxygen forms at the anode. The presence of sulfate does not mean sulfur is deposited.
Specification references
AQA 8462 sections 4.4.3.1, 4.4.3.2, 4.4.3.4 and 4.4.3.5; Pearson Edexcel 1CH0 Issue 4 points 3.22–3.29. Both boards limit writing half equations to Higher tier.