What is formed at the anode and cathode when the following solutions are electrolysed?

sodium iodide
copper II chloride
sodium sulphate
NaOH
HCl
magnesium nitrate

also is this true: if the metal in the compound is higher in the reactivity series than hydrogen then hydrogen is produced instead of the metal at the positive electrode.

When a solution is electrolyzed, the anode (positive electrode) and cathode (negative electrode) perform different reactions based on the substances present in solution.

1. Sodium Iodide (NaI):
At the anode: Iodide ions (I-) are oxidized to iodine gas (I2).
At the cathode: Sodium ions (Na+) are reduced to sodium metal (Na).

2. Copper II Chloride (CuCl2):
At the anode: Chloride ions (Cl-) are oxidized to chlorine gas (Cl2).
At the cathode: Copper II ions (Cu2+) are reduced to copper metal (Cu).

3. Sodium Sulphate (Na2SO4):
At the anode: Hydroxide ions (OH-) are oxidized to oxygen gas (O2) and water (H2O).
At the cathode: Hydrogen ions (H+) are reduced to hydrogen gas (H2).

4. Sodium Hydroxide (NaOH):
At the anode: Hydroxide ions (OH-) are oxidized to oxygen gas (O2) and water (H2O).
At the cathode: Hydrogen ions (H+) are reduced to hydrogen gas (H2).

5. Hydrochloric Acid (HCl):
At the anode: Chloride ions (Cl-) are oxidized to chlorine gas (Cl2).
At the cathode: Hydrogen ions (H+) are reduced to hydrogen gas (H2).

6. Magnesium Nitrate (Mg(NO3)2):
At the anode: Nitrate ions (NO3-) are oxidized to oxygen gas (O2) and nitrogen dioxide gas (NO2).
At the cathode: Magnesium ions (Mg2+) are reduced to magnesium metal (Mg).

Regarding the statement about the reactivity series and the production of hydrogen, it is true. If the metal in the compound is higher in the reactivity series than hydrogen, then hydrogen gas will be produced instead of the metal at the positive electrode (anode). This is because more reactive metals have a stronger tendency to lose electrons and form positive ions, leading to the oxidation of water, and the evolution of oxygen gas and hydrogen ions. Less reactive metals will be displaced by hydrogen ions, resulting in the production of hydrogen gas.