How to check whether Python script has elevated privileges?

It may happen that a Python script needs root privileges on Linux / macOS or admin privileges on Windows to run properly. If it does not have them, there is no point in continuing. Let’s see how to quickly check whether the current runtime has those privileges.