A training to acquire strong basis in Python to use it efficiently
Pierre Augier (LEGI), Cyrille Bonamy (LEGI), Eric Maldonado (Irstea), Franck Thollard (ISTerre), Christophe Picard (LJK), Loïc Huder (ISTerre)
Repository containing the source of this training:
https://gricad-gitlab.univ-grenoble-alpes.fr/python-uga/py-training-2017
A very nice and well-thought programming language.
Generalist: good for several applications, used with success in many fields.
For academic purposes (teaching, research): great scientific ecosystem.
Python is a programming language.
It is first an interpreted language (like Bash, Matlab, and in contrast with Fortran, C or C++), so we need an interpreter, i.e. a binary parsing Python code and running computer instructions.
Open a terminal. There are usually different python commands: python
, python2
and python3
.
2 languages, 2 interpreters, 2 commands
On Linux, there are the system python binaries.
On Windows, Mac (and Linux), you can install and use
(advice on how to install a good scientific Python environment)
In some systems (cluster), there are modules:
module load python
Download the repository of this training (you need one of the programs git
or mercurial
). On Unix machines, use the commands:
git clone https://gricad-gitlab.univ-grenoble-alpes.fr/python-uga/py-training-2017.git
# or with Mercurial:
# hg clone https://gricad-gitlab.univ-grenoble-alpes.fr/python-uga/py-training-2017.git
cd py-training-2017
cat README.rst
make help
Warning: cat
and make
are Unix commands...
python3
¶Run a script with python3
(pyfiles/helloworld.py is just a text file):
cat pyfiles/helloworld.py
python3 pyfiles/helloworld.py
(cat
is a Unix command that print the content of a text file.)
2 + 2
4
3 / 4
0.75
run ../pyfiles/helloworld.py
Hello world My name is Pierre
# name is defined in ../pyfiles/helloworld.py
print(name)
Pierre
name?
Try to type "name." and to press on tab... The tab key is used to tell you how what you typed can be completed.
Try to use the top and bottom arrows...
Launch the application Spyder, a Python IDE (Integrated development environment).
Remarks: