Dear student
the electric fan work on principle that it converts electric energy into mechanical energy
the electric generator works on the principle that it converts mechanical energy into electrical energy and same has been done by electric dynamo it also converts the mechanical energy into electrical energy.
Regards