These are scrap book notes on the basics of Python Programming. This is not meant to be definitive guide as there is no “correct” way to play with linux..
I use two distros, Debian and Arch Linux. The body of reference used for the notes is “Python Programming for the absolute beginner, Michael Dawson. If you are new to Python, there are various versions of Python. The book uses Python 3.1.1.
The Raspberry Pi comes with python and related tools pre-installed but if you are new to Python and Linux then you may not realise (as I have done) to use the correct versions on a separate Linux box.
There are many articles on how to download Python version 3.x – the easiest method is
Open root in your favourite terminal and run the following
apt-get install python3.2
once loaded exit out of root and your may open python via the GUI or type
on the command line. Debian comes preloaded with various versions of python so stating the version is important if using the command line.
Why do I mention this? Because this affects the way the syntax is used. There are also various programs that you are able to use to code in Python; Vi Editor, IDLE, Gedit etc..
The one that I am using is IDLE as it is the easiest because it is specifically designed to be used with Python. To download,
Open as root in the terminal of your choice. Run the following command;
apt-cache search idle
this comes up with a list of results. The one to look out for is
I have loaded the latter by running the following command
apt-get install idle-python3.2
exit out of root and to run idle from the command line type the following
Writing your first program – open idle and type the following.
in order to run the program you will have to save it, so do so in a folder of your choice. Then hit F5.. it should print out hello world
The task of the print () function is to display a value (or a sequence of values). You can call a function by using the function name followed by a set of parentheses. You can also pass a function values to work with called arguments between the parentheses.
In the example above you passed the print () function with the argument “hello world”, which the function used to display the message hello world
More to follow..