Versions of Python
Today (2014) are available two version of Python and are:
Python 2.x.x
Python 3.x.x
The differences from this two version are in the links below.
The standard librariers of Python are here:
In this manual I used the Python v.2.7.3.
For check if Python is present on your RaspByan
use the command below:
python -V
The answer must be similar to this (see below):
From a terminal if you write: Python
you enter in the command
interpreter and you
have the possibility to test immediately the syntax of Python.
For exit from the interpeter type: exit()
Very useful is the utility pip that is a tool for manage
the Python libreries.
For instal pip use the command below:
sudo apt-get install python-pip
Basically
the structure of the programs is accomplished simply identation
(aligning with the right TAB) the instructions you write.
You no longer need to declare variables before using them.
The data types are automatically assigned according to the contents
used during the assignments.
Python has the following keywords or reserved words; they cannot be
used as identifiers
Here some link regarding Python.
For execute a Python program you must use the
syntax below.
NOTE:
#!/user/bin/python
Our first Python program
Write in P1.py the lines below.
Save the file (ctrl + X) and next use the command:
python P1.py
if you did everything correctly you must see something like this:
Of course there are Integrated
Development Environments (IDE)
that make life easier for programmers.
Look for example here: