Electrolysis is where electricity is used to break down a compound. It is used in the extraction of metals that are more reactive than carbon, or where the metal must be very pure.
The electrodes are connected to a battery and placed in the solution or molten substance. As the current flows through the electrolyte the metal is deposited as a layer on the negative electrode.
The positive electrode is called the anode and the negative electrode is called the cathode.
Copper is purified this way because very pure copper is needed for electrical wiring. A block of impure copper is used as the anode and a strip of pure copper is used as the anode. Copper sulphate solution is used as the electrolyte. When the current is flowing, the electrons are pumped out of the anode onto the cathode. The copper atoms on the anode have some electrons stripped away, making them copper ions which go into the solution. These copper ions are positively charged as they have lost electrons, so they are attracted to the cathode. When they reach the cathode, they are given electrons which makes the ions in atoms again and they are left on the cathode. All the impurities get left in the bottom of the tank, the big block of impure copper gradually wears away and the pure copper strip gets bigger.