A transformer operates on the principle of electromagnetic induction. It consists of two or more coils of wire, known as the primary and secondary windings, which are wrapped around a core. When an alternating current (AC) flows through the primary winding, it creates a varying magnetic field around the core. This varying magnetic field induces a voltage in the secondary winding. The voltage induced in the secondary coil depends on the ratio of the number of turns in the primary coil to the number of turns in the secondary coil, thus allowing the transformer to increase or decrease voltage levels efficiently.