Final answer:
When the switch of an electromagnet is closed, the soft-iron nails are attracted to the now magnetized iron core due to electromagnetic induction. Once the switch is opened and the power is cut, the magnetic field collapses and the nails fall away since they are no longer magnetically attracted.
Step-by-step explanation:
When the switch is closed, the battery energizes the electromagnet, creating a magnetic field around the soft-iron core.
This magnetic field induces magnetism in the soft-iron nails below, causing them to be attracted and stick to the soft-iron core.
When the switch is opened after a few seconds, the electromagnet loses its power, and the magnetic field collapses.
Consequently, the induced magnetism in the nails also disappears, and they will fall away from the core because they are no longer magnetically attracted to it.
This behavior is consistent with the principles of induction and electromagnetism, which show that a changing magnetic field can induce an electromotive force (emf) and, consequently, a current in a nearby conductor - in this case, the electromagnet's core affecting the nails.
Each time the magnetic field is changed (when the switch is closed or opened), an emf is induced.
However, when there is no change (switch remains in one state), there is no magnetic field change, and thus no induction.