To use this code, you'll have to install a fan. The full instructions can be found on our guide: Control Your Raspberry Pi Fan (and Temperature) with Python.
If you are doing anything that is CPU intensive, your Raspberry Pi heats up. The Raspberry Pi 3 ran hotter than the models before, and the Raspberry Pi 4 runs even hotter. If the CPU were to run too ...