Subsections

How to use Python?

There are two ways to use Python. The one is interactive within the python console and then the other method is by running a python script.

Development environments such as anaconda have both the console and then scripting facility integrated under one roof.

The python console

The python console you can just start by typing “python”:
Python 3.8.10 (default, Jun  2 2021, 10:49:15) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
then you can type in commands one by one. Under Windows you might need to point the PATH variable to your python program or you let Anaconda do it for you.

Python scripts

Scripts are text files which contain python commands. One command per line and these are executed line by line.

Write your commands in any text editor and save it as a .py-file. However, it's recommended to use an editor which supports at least python's indentation which is a very important feature of python. We'll see that indentation in python defines the body of a function, the content of a loop or the code executed conditionally.

So, it's recommended for any serious work to install an editor which supports python such as spyder, VS-code, py-charm or emacs.

Once you have your script file saved just type “python myscript.py” and it will be executed.

Help

There is an abundance of online help available for Python. The official Python pages have an excellent tutorial (https://docs.python.org/3/tutorial/) and of course you find answers to all your questions on Stack Overflow.

If you need help for a function you can use the in built help function “help(thecommand)” to get help for “thecommand”. Try out “help(print)” to get help for the “print” command.

github / contact

Creative Commons License