Making Sense of Location Based Services

Tender beginnings with Python

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

python3.2

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

idle3 or

idle-python3.2

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

idle-python3.2

Writing your first program – open idle and type the following.

print(“hello world”)

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..

Latest Posts

  • RFID, Raspberry Pi & LBS
    The experimentation with Raspberry Pi goes on. RFID is the next stage in effective Indoor Location Based Services and to understand this the following is a small project that brings RFID to the Raspberry Pi. A brief history of the...
    Read more
  • Hacking Location Based Services & IoT with the Raspberry Pi
    Introduction There are very exciting topics that influenced me over the past few years namely Location Based Services (LBS), The Internet of Things (IoT) and the humble Raspberry Pi.  But first a brief background – I am not a technical...
    Read more
  • Arch Linux OpenVPN Server on Raspberry Pi (part 2)
    Once yaourt has been configured, download the “netcfg” package by issuing the following commands; yaourt netcfg There will be a list of programs that have netcfg as a search string. Choose the netcfg by the appropriate number: If you are...
    Read more
Linux Format Magazine
LBSZone

Twitter: global_lbs