The purpose of a generator is to convert motion into electricity. This wouldn't be possible if it wasn't for one fact: That a wire passing through a magnetic field causes electrons in that wire to move together in one direction.
A loop of wire spinning through a magnetic field will create an alternating current.
Note: current will flow only if the circuit connected to the generator is complete.
A generator consists of some magnets and a wire (usually a very long one that's wrapped to form several coils and known as an armature). A steam engine or some other outside source of motion moves the wire or armature through the magnetic field created by the magnets.
In the example to the left, a loop of wire is spinning within a magnetic field. Because it is always moving through the field, a current is sustained.
But, because the loop is spinning, it's moving across the field first in one direction and then in the other, which means that the flow of electrons keeps changing.
Because the electrons flow first in one direction and in the other, the generator produces an alternating current.
One advantage that AC has over DC is that it can easily be "stepped up" or "stepped down" with a transformer. In other words, a transformer can take a low-voltage current and make it a high-voltage current, and vice versa.
This comes in handy in transmitting electricity over long distances. Since AC travels more efficiently at high voltages, transformers are used to step up the voltage before the electricity is sent out, and then other transformers are used to step down the voltage for use in homes and businesses.