Electromagnets are used in MRI machines. Electromagnets are commonly used in motors, speakers, and doorbells.
All magnets produce a magnetic field.

All magnets have a north and south pole. Magnetic poles are the strongest parts of a magnet.
North and south poles of magnets attract each other. The two south poles and the two north poles repel each other.
A magnetic field is the area around a magnet that attracts and repeal objects. If you place an object inside the magnet’s field, it will be attracted to the magnet. The simplest way to see a magnetic field is to sprinkle iron filings around a magnet.
Iron filings are tiny pieces of iron. When sprinkled around a magnet, they reveal the magnetic field.
The Earth also has a magnetic field – it is like a huge magnet. Compasses work because the needle inside the compass is a magnet. One side of the needle is the north pole and the other side of the needle is the south pole. The north pole of the needle is attracted to the North Pole and the south pole of a needle is attracted to the South Pole.