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 compass needle sets itself along the field acting on it, and like poles repel.
(a)
Step 1 — Follow the current into the coil.
In Fig. 10.19, the long plate of the battery (its + terminal) is joined to the end A of the coil, so the current enters the coil at A and flows up the front of each turn.
Step 2 — Apply the clock rule.
Seen from end A, this current goes round anticlockwise, so A is a north pole. Seen from end B it goes clockwise, so B is a south pole.
(b)
Step 3 — Find the field at the compass.
The compass is to the west of end A. The field lines come out of the north pole A, so just beyond A the field points away from A, towards the west.
Step 4 — Find how the needle turns.
The north pole of the needle is repelled by the north pole A and turns along this field, so it is deflected towards the west, away from the coil.
The figure shows A as N and B as S, with the field just beyond A pointing west and the north pole of the needle turned towards the west.

Watch out: The battery's long plate is its positive terminal; reading it the other way reverses both poles and the deflection.
Therefore, (a) A becomes a north pole and B a south pole, and (b) the north pole of the compass needle is deflected towards the west, away from end A, because the north pole A repels it.