Open a terminal, move to your folder, and run a Python script.
A terminal is a text window where you type commands to your computer instead of clicking. Every operating system ships one. You run the builds from here.
The terminal is always sitting inside one folder, called the current working directory. Commands act relative to it, so where you are matters.
cd path/to/your/folder
Use this to move into the folder that holds your script before you run it.
Save your code as a file, for example q_learning.py, then run:
python3 q_learning.py
Typing python3 on its own opens an interactive prompt, the REPL, where you run one line at a time. Running python3 file.py runs a whole file start to finish. The builds are files, so use the file form.
Press Ctrl-C in the terminal to interrupt a running script.
cd into it first.cd errors with a syntax message, you are probably inside the Python REPL. Type exit() to leave it.q_learning.py.txt. Turn on "show file extensions" and check the real name.