After writing the code in Python, you have to save your file in the .py format.
Now, you have to open the terminal by pressing Ctrl+Alt+T.
After that, you can navigate the terminal to the directory where the .py file is located using the following:
cd path_of_the_file
After setting the path, in the terminal, you can write the following to execute the script:
python SCRIPTNAME.py
If your script is written in Python3, then you should write:
python3 SCRIPTNAME.py
If you are looking for an online course to learn Python, I recommend this Python Course by Intellipaat.