Does turning a lighbulb on and off repeatedly use more energy than just leaving it on for hours?
Leaving it on would use more energy, absolutely. Sometimes, people try to convince themselves that turning a light on and off uses more energy because there is some high inrush current, or some such thing.

Firstly, incandescent lights hardly have any inrush current, because they don't have any capacitors to charge, and they need not strike an arc in the bulb. The current is initially higher because the filament resistance is lower, but:


this is for a fraction of a second
getting it up to temperature doesn't take any more energy than it would have taken to leave it on to maintain that temperature
even though the current may be higher, it's not that much higher. Do all the other lights in your house dim temporarily when you turn one on?


Secondly, if you take a fluorescent bulb, which may have capacitors, and thus may require some inrush current, it doesn't begin to make up for the cost of leaving the light on. Consider again how short the turn-on period is relative to the leaving-on period. Even if you consider the wear-and-tear on the bulb and the starter and the fixture, it's almost always more economical to turn the bulb off. I read a report by someone who bothered to do all the math, and they concluded that if you intend to leave the light off for more than about 60 seconds, it's more economical to do so.