How can pedal power create electricity?

Some people have adapted stationary bicycles to run an alternator or generator instead of a rear wheel. This then creates eletricity that can power lights or radios and other small electric devices