Ubuntu 18.04 is shipped with Python 3.6, but most of us want to be able to install newer Python versions. I’m using Apt and the deadsnakes PPA, which contains new Python versions packaged for Ubuntu (read here about PPA).
First we install the prerequisites (which might already have been installed), then we add the deadsnakes PPA and finally we install the newer Python version (in this case 3.8).
And to verify that the correct version has been installed:
The Python versions that came with Ubuntu 18.04 are still there:
If you want to change python3 to point to the newly installed version, you can change the link /usr/bin/python3.
NOTE! Don’t change python to point to any python3 version. There are still software that depends on 2.7 and it will break things. python on Ubuntu still needs to be version 2.7.