When you read a standard Physics textbook it will usually give the speed of sound as being roughly 330-340 m/s, depending on the book. When books quote this value they aren't actually quoting a constant, they're telling us the speed of sound specifically at sea level and at 15 degrees celsius (the average air temperature over land). But at -50 degrees (the temperature in certain parts of Antarctica) the speed of sound can drop to below 290 m/s. And at higher temperatures, 50 degrees say, it can speed up to over 360 m/s. In other words, sound will travel faster in hotter air than in colder air. What's going on?
Sound is the result of air particles being spread out from a vibrating object (a voicebox, a ruler twanging on a desk) and then crashing into a bunch of nearby paticles. As they crash into this nearby bunch, all the particles are momentarily squashed together, creating a dense spherical shell around the source of the sound. But then, the particles rebound from each other and we end up with the exact opposite, a shell of really sparse air with not many particles in it. This bouncing-off-each-other effect then gets repeated as the particles are sprayed out further, bumping into a new shell of air particles and so on.
The result is that we get a sphere of compressions spreading out from the surface of the vibration, and then a smaller sphere of rarefactions (spread-out air), and then a smaller inner sphere of compressions, and then so on on. We end up with a sort of gobstopper structure of alternating compressed/expanded regions of air spreading out from a point. We call the outermost shell of this soundwave a wavefront. When the wavefront hits your ear, the eardrum is pushed back and forth as the soundwave repeatedly crashes into it, sending electrical signals to the brain which we interpret as sound.
Lots of things can affect how fast this wave of air-ripples can travel but the main factors are: speed the particles are moving at, the density of the particles (how many there are in a given volume) and the pressure they are exerting on each other. There's a nifty equation which links them all, saying, roughly that the speed of a wave is calculated as the square root of the rate of change of pressure, per rate of change of density. What it means is that if the air is doing different things and has different densities, pressure and particle-speeds, we'll get a different soundwave speed.
The two main things which affect sound speed are altitude and temperature. Near the surface of the Earth, the air is quite thick because the particles are all pulled together under gravity, giving us a speed of around 340 m/s. But about 10 km up, the air is a lot thinner, and so as particles are spread out from the vibration source they don't bump into each other as often, the compression doesn't immediately form, causing the bounce-back, so the overall speed of sound is a little slower (around 300 m/s).
The most confusing, and surprising, factor however is that sound travels faster in hotter air. Your instincts would say that it should go slower, since hotter air is less dense (and we've just learnt that less density usually means slower speed), but it turns out particle speed has more of an effect on overall wavefront speed. Hotter air is full of particles that move faster, and so they are quicker to "rush in to fill the gaps" in a progressing wavefront. It's actually as simple as: faster air = faster vibrations.
So the speed of sound is hardly constant at all. Sound will travel differently on different days and at different altitudes. They all cluster around a similar-ish mean value (300 m/s) because the density of a gas hovers around a specific value on Earth, and particle impact energies all have a definite constant force associated with them, but the speed of sound can fluctuate with the weather.
The speed of light is much the same, having a constant value only in a vacuum but being slower in certain mediums like glass and water. The only thing known to travel faster than the speed of light is the speed of rock and roll.