A car horn is a remarkably simple electro-mechanical device. In its simplest and most common incarnation, it's simply a steel plate and an electromagnet. Block diagram thusly:
| 7 <-- This is a switch, which is in contact
L | 3 when the diaphragm is at rest
| 3 or farther from the electromagnet,
| 3 here, and which controls the current
| 3 <____| to the electromagnet
^The steel diaphragm, here, is attached with something springy.
So in operation, one presses the horn, the electromagnet attracts the diaphragm while the switch is in contact, then is released to travel back past neutral position by Hooke's law (the spring), closing the switch again, and thereby pulling the diaphragm back, setting up an even left-right oscillation.
This diabolical device can be used for many and splendid purposes, but it is worth considering that in many jurisdictions, using the car horn for anything but "preventing an imminent accident" is an infraction. That said, it's good for waking up that numbskull ahead of you who has dosed off at the now green light, for scaring off wildlife who happen to wander into the roadway, making sure someone merging into the lane knows you're there, attracting attention (some car alarms use the horn), notifying someone that you've arrived to pick them up, etc...
The note of one's horn is determined by the collusion of such factors as: the springy-ness of the attaching matrix, the power of the electromagnet, the mass of the diaphragm, and how it's arranged, and how the switch is placed. A car horn is also an extremely good way to drain a car battery, in that for about half the time you're pressing the horn, the electrical system is basically shorted. Expect a car with its horn on to last for a couple of hours, tops.
These days, though, one can get much more fancy, as all the horn switch does is apply 12 volts DC across something, it doesn't care if it's the device described above, a car alarm (as described in modifying a car horn), or some fancy 'play any midi you download into the damn thing with bluetooth' kind of thing (or just plays La Cucaracha or the first twelve notes of Dixie if you're driving General Lee). Really, anything that makes a metric fuckton of noise out of 12 volts DC is acceptable, though some things may function better than others (a horn sound VS a 120dB sample of a kitten meowing). I seem to remember a The Fabulous Furry Freak Brothers cartoon where they replaced the horn on their Volkswagen Beetle with an extremely loud sample of an atomic bomb going off. That worked.
Thanks to SharQ for reminding me to mention what one uses th' horn for, and suggesting things to discuss.