Both the book and the code seem to assume a PNP transistor, saying that a low from the Pi will turn the transistor on, thus energising the relay. Since the circuit actually uses an NPN transistor, which turns on for a high from the Pi, the relay is actually energised when the Pi sends the pin high.
The output on the screen shows the opposite of what the relay and LED are doing.
Both the book and the code seem to assume a PNP transistor, saying that a low from the Pi will turn the transistor on, thus energising the relay. Since the circuit actually uses an NPN transistor, which turns on for a high from the Pi, the relay is actually energised when the Pi sends the pin high.
The output on the screen shows the opposite of what the relay and LED are doing.