Transformers are everywhere, though they're well hidden. Chances are, if you have any electronic device or machine that plugs into a wall, then it likely has a transformer within to convert the high voltage 120 or 240 VAC into more modest AC voltages that are then rectified to power DC devices. Transformers form the bulk of the volume and mass of "wall warts" that power most modern electronics. Why are they so heavy? What do they do? How do they do it?!
Design
A "typical" transformer has three main parts: the primary coil, secondary coil, and the core. The coils consist of tightly wound copper wires, the number of turns of said wires dictating what effect the the transformer will have on the voltage applied. Primary and secondary are relative terms when it comes to describing a transformer. The primary coil is the input coil, and the secondary is the output coil, swap the two and you can simply refer to them in reverse. While the labels aren't as important, the design of each coil does. Generally, the two coils will be wound with a ratiometric configuration, that is one coil typically has fewer turns of wire than the other. These coils are wrapped adjacent to each other around a usually laminated iron core (hence the heft)
Operation
Transformer operation relies on changing magnetic fields that induce a current from one coil to the other. A transformer requires an AC voltage across its primary coil in order to induce a current in the secondary coil. The rapidly changing magnetic field, the magnetic flux, is carried through the iron core from one coil to the next. The input is AC, thus the output is AC as well. The ratio of the coils determines whether the transformer will boost (increase) or buck (decrease) the voltage to the secondary. A low turn count in the primary and a high turn count in the secondary will result in a higher voltage across the secondary. You can use the equation: Vs = Vp * (Ns/Np) The voltage across the secondary is equal to the voltage across the primary multiplied by the number of turns in the secondary divided by the number of turns in the primary. For instance, if you ran 120 VAC across the primary coil with 200 turns and the secondary coil had 500 turns of wire, then ideally you'd have:
Vs = 120 * (500 / 200)
Vs = 120 * 2.5
Vs = 300
Also, although transformers are bidirectional, it is important to always use the manufacturer's recommended operation, as part of the transformer may not be rated for certain currents.