Solution:
Concept: Clock rule: Look at one face (end) of a current loop or solenoid. If the current at that face flows anticlockwise, the face behaves as a north pole; if it flows clockwise, the face behaves as a south pole.
(a)
Step 1 — Follow the current.
The current leaves the + terminal of the cell (its longer, thinner plate, on the left), passes through the key K and enters the coil at end A.
Step 2 — Find its sense at end A.
From A the wire goes up across the front of the solenoid and down at the back. Seen from end A, this current flows anticlockwise.
Step 3 — Apply the clock rule.
An anticlockwise current makes end A a north pole, so the other end, B, is a south pole.
(b)
Step 4 — Compare the facing poles.
The north pole of the small magnet faces end A, which is now also a north pole. Like poles repel, so the magnet is repelled, pushed away from the solenoid.
The figure marks A as N and B as S, with the magnet's N facing A and pushed away from the solenoid.

Watch out: Find which terminal of the cell is + (the longer plate) before tracing the current; reversing the cell would make A a south pole and the magnet would be attracted.
Therefore, (a) end A is a north pole and end B is a south pole, and (b) the magnet is repelled, because like poles (the N of the magnet and the N at end A) repel each other.