An electric motor converts electrical energy into mechanical energy by using a rectangular coil placed in a magnetic field that rotates when current is passed through it. An electric generator operates on the reverse principle, converting mechanical energy into electrical energy by inducing current in a conductor that is moved through a magnetic field. There are two main types of electric generators: alternating current and direct current.