Apple stopped including the Python 2.7.* distribution with macOS 12.3. Optionally, Xcode and the Command Line Tools for Xcode both install an older version of Python 3.9.6 in /usr/bin. I don't use that version.
Visit Python.org and select Download. Choose their Python 3.11.4 (Universal2) installer and once it has downloaded, double-click its proper Mac installer to commence the installation. It will place links in /usr/local/bin for Python3, idle3, pip3, and so forth back to their actual installation location in:
/Library/Frameworks/Python.framework/Versions/3.11/bin
It will also create a /Applications/Python 3.11 folder.
You then plain text edit your shell dot file (e.g. ~/.zshrc for the Zsh shell, or ~/.bash_profile for the Bash shell) by changing the PATH environment variable to find the Python binaries and library:
export PATH=".:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"
and then depending on the shell:
source ~/.zshrc
source ~/.bash_profile
either of which will set the current Terminal session PATH as you have changed it.
Then, any Python script should begin with:
#!/usr/bin/env python3
or you can run a Python3 compatible script as:
python3 thiscript.py
Here is an example that you can try:

chmod +x ./ranimg.py
./ranimg.py ~/Pictures
It will randomly print the full path to a single image in your Pictures folder.