introduction to python
DESCRIPTION
Guy Griffiths. Introduction to Python. What is Python?. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party libraries (currently 21,054 on the main python package website) Free!. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/1.jpg)
Guy Griffiths
![Page 2: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/2.jpg)
General purpose interpreted programming language
Widely used by scientists and programmers of all stripes
Supported by many 3rd-party libraries (currently 21,054 on the main python package website)
Free!
![Page 3: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/3.jpg)
Numpy Numerical library for python Written in C, wrapped by python Fast
Scipy Built on top of numpy (i.e. Also fast!) Common maths, science, engineering routines
Matplotlib Hugely flexible plotting library Similar syntax to Matlab Produces publication-quality output
![Page 4: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/4.jpg)
![Page 5: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/5.jpg)
An integrated graphical environment like Matlab (although there are tools which put it in one – e.g. Spyder)
Specifically designed for scientists/mathematicians (but the 3rd-party libraries for plotting/numerical work are some of the best around)
High performance (but it is very easy to wrap C/Fortran libraries in Python code)
![Page 6: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/6.jpg)
Yahoo Maps/GroupsGoogleNASAESRILinux distrosMet OfficeMe
![Page 7: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/7.jpg)
How about several cool things that Python can do?
![Page 8: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/8.jpg)
![Page 9: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/9.jpg)
![Page 10: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/10.jpg)
![Page 11: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/11.jpg)
Interactive prompt is great for experimenting iPython is a fantastic interactive environment I mostly write code in iPython interactively,
then copy it out into a script when I’m done
print is easy and intuitive to use Yes, you should use a proper debugger, but
let’s face it – print statements are quicker and easier.
Well, print statements in python are even quicker and easier than that.
![Page 12: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/12.jpg)
Readable code You have to indent all of your loops,
conditionals, etc. This means that your code will always be
indented in a helpful way Inline documentation
![Page 13: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/13.jpg)
3rd-party libraries Numpy, Scipy, Matplotlib are standard
libraries for scientific computing cf-python is written with meteorologists in
mind There are 3rd-party libraries for many,
many things If you want to do something that isn’t
particularly uncommon, there will be a library to do it for you
![Page 14: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/14.jpg)
No. But python can wrap your existing C/Fortran/R code... You can get the benefits of a high-level
language whilst keeping your fast C/Fortran routines
This is what Numpy does (and why Numpy is fast)
...and Matlab code translates pretty easily to python.
![Page 15: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/15.jpg)
A good language to teach Questions you won’t hear if you teach
python:▪ “What does ‘Segmentation fault’ mean?”▪ “Why do I have to click ‘build’ before I run this
every time?”▪ “Do you know where I can download a license for
this so I can use it at home?” Questions you may still hear:▪ “What’s a variable?”▪ “Why do we have to do this?”
![Page 16: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/16.jpg)
Let’s have a look at a few python libraries in action
![Page 17: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/17.jpg)
Firstly, get version 2.7.x. Python 3 is probably more trouble than it’s worth right now.
Windows – Python(x,y) [www.pythonxy.com]This is a scientific/engineering oriented distribution of python. It includes everything you need to get started
Linux – it’s already there! Unless you’re running a very unusual distro (in which case you probably already know what you’re doing).
Mac – it’s already there on OS X, but it’s old. Get a more up-to-date one [www.python.org]
![Page 18: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/18.jpg)
The official python tutorial:http://docs.python.org/tutorial/
Software Carpentry:http://software-carpentry.org/
Dive into Python:http://www.diveintopython.net/
Learn Python the Hard Way:http://learnpythonthehardway.org/
A Byte of Python:http://www.ibiblio.org/g2swap/byteofpython/read/
![Page 19: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/19.jpg)
Python Essential Reference David M. Beazley (Addison Wesley)
Programming in Python 3: A Complete Introduction to the Python LanguageMark Summerfield (Addison Wesley)
Learning PythonMark Lutz (O’Reilly Media)
![Page 20: Introduction to Python](https://reader035.vdocument.in/reader035/viewer/2022062517/56813b13550346895da3c16a/html5/thumbnails/20.jpg)