For all the installed python 3 base packages (e.g. "python3.6", "python3.8"):
$ dpkg -l | grep "^ii" | grep "python" | awk '{print $2}' | grep "python3\.[0-9]$"
python3.6
python3.8
Basically, once you understand the above you can find anything. The key is to realize that the output from dpkg is actually in its own special format, so the line with the base python3.6 package is:
ii python3.6 3.6.9-1~18.04ubuntu1.3 amd64 Interactive high-level object-oriented language (version 3.6)
Yeah, the "ii" (indicating the package is fully installed) at the beginning of each line messed me up too. The final grep lets you narrow the search to the base executable. The package name is in column 2 ("$2"). Single or double quotes work fine, except for the awk statement, that requires single quotes around the braces (double quote anything inside that). You actually don't need to filter for "ii", but realize you might then get results for removed packages whose config still exists ("rc").
If I don't mind getting all the packages related to each version, I could do this:
$ dpkg -l | grep "python3\.[0-9]" | awk '{print $2}'
libpython3.6:amd64
libpython3.6-dev:amd64
libpython3.6-minimal:amd64
libpython3.6-stdlib:amd64
libpython3.8:amd64
libpython3.8-dev:amd64
libpython3.8-minimal:amd64
libpython3.8-stdlib:amd64
python3.6
python3.6-dev
python3.6-minimal
python3.6-venv
python3.8
python3.8-dev
python3.8-minimal
Notice I didn't filter on "ii". To show all the packages for a specific version, you can do this:
$ dpkg -l | grep "python3.8" | awk '{print $2}'
libpython3.8:amd64
libpython3.8-dev:amd64
libpython3.8-minimal:amd64
libpython3.8-stdlib:amd64
python3.8
python3.8-dev
python3.8-minimal
So when you're grepping a dpkg list you need to realize that the package name name is actually in column 2, and the version in column 3. All this invoking of awk might seem cumbersome, but only because you're not used to it. Learn to love awk, awk is your friend. Microsoft has never created anything as awesome as awk.
Here's the same output with the extended version info from column 3 (notice the tab inserted in between):
$ dpkg -l | grep "python3\.[0-9]" | awk '{print $2 "\t" $3}'
libpython3.6:amd64 3.6.9-1~18.04ubuntu1.3
libpython3.6-dev:amd64 3.6.9-1~18.04ubuntu1.3
libpython3.6-minimal:amd64 3.6.9-1~18.04ubuntu1.3
libpython3.6-stdlib:amd64 3.6.9-1~18.04ubuntu1.3
libpython3.8:amd64 3.8.6-1+bionic2
libpython3.8-dev:amd64 3.8.6-1+bionic2
libpython3.8-minimal:amd64 3.8.6-1+bionic2
libpython3.8-stdlib:amd64 3.8.6-1+bionic2
python3.6 3.6.9-1~18.04ubuntu1.3
python3.6-dev 3.6.9-1~18.04ubuntu1.3
python3.6-minimal 3.6.9-1~18.04ubuntu1.3
python3.6-venv 3.6.9-1~18.04ubuntu1.3
python3.8 3.8.6-1+bionic2
python3.8-dev 3.8.6-1+bionic2
python3.8-minimal 3.8.6-1+bionic2