Note that there is a mistake in the published article in MagPi 40.
The command to install the HCSR04 library should be:
sudo pip3 install gpiozero hcsr04sensor