Python: Introduction for Absolute Beginners

Python: Introduction for Absolute Beginners

Bob Dowling University Computing Service

Scientific computing support email address:

scientific-computing@ucs.cam.ac.uk

These course notes:

www-uxsup.csx.cam.ac.uk/courses/PythonAB/

1

This is the UCS three afternoon course on Python for people who have no experience of programming at all. We warn all those people who do have some programming experience and who are here just to add the Python notch to their bed post that they will be excruciatingly bored in this course. Those people who do already know how to program in another language and want to learn Python are better off attending the UCS "Python: Introduction for Programmers" one day course. For details of this course, see

Note that the UCS Python courses cover Python 2.4 to 2.6, which are the most common versions currently in use ? it does NOT cover the recently released Python 3.0 since that version of Python is so new. In some places Python 3.0 is significantly different to Python 2.x, and this course will be updated to cover it as it becomes more widely used.

The official UCS e-mail address for all scientific computing support queries, including any questions about this course, is: scientific-computing@ucs.cam.ac.uk

Course outline -- 1

Introduction

Using Python like a calculator

Who uses Python? What is Python? Launching Python

Types of value Numbers Text Truth and Falsehood Python values

2

So what will this course cover?

We will start with a brief introduction to Python, looking briefly at what it is used for and how we launch it on the systems being used for this course.

Once we have it running we will start by using it as a glorified calculator to get us used to its features. We will examine how it handles numbers, text and the concept of a statement being true or false.

Course outline -- 2

Using Python like a programming language

We will do lots with lists.

Variables if...then...else... while... loops Comments

Lists for... loops Functions

Tuples Modules

3

But Python is there for us to use as a programming language so, after spending a while using it as a manually operated calculator, we will start to use it as a fully-fledged programming language.

As part ofd this we will look at how Python stores values and assigns names to these stored values. We will look at the three fundamental constructs that will allow us to build programs that actually do something. ("if...then...else...", "while... loops", and "for... loops")

We will also spend a lot of time looking at how Python handles lists. There are two reasons for this. First, Python uses lists a lot so we need to understand them. Second, Python lists are the first example of a computer data structure that doesn't have any analogue in the usual arithmetics.

Then we will look at writing our own functions that use what we have learnt. Functions permit us to structure our code in a more maintainable fashion. We will look at how Python groups related functions together and what groups of functions is provides ready-made. These groups are called "modules" in Pythonic language.

Course outline -- 3

Interacting with the outside world

Built-in modules The "sys" module Reading input

Files

Storing data in programs

Dictionaries

4

Once we know the rudiments of programming in Python we will look at the support functions offered by the base Python system. These will let us access the system outside of Python. The main example of this will be accessing the file system. Finally we will look at one last, very powerful mechanism for storing data, the "dictionary".

What is Python used for?

Network services

Web applications

GUI applications

CLI applications

/usr/bin/command-not-found

Scientific libraries

Instrument control

Embedded systems

5

I want to start by convincing you that learning Python is worthwhile. Python is used for every scale of operation. Here is a spectrum of examples running from the largest to

the smallest.

The Massively Multiplayer Online Role-Playing Game (MMORPG) "Eve Online" supports over 300,000 users with a Python back end.



Two very common frameworks for web applications are Django (general purpose) and Plone (content management). Both are implemented in Python.





On the desktop itself there are frameworks to build graphical applications in Python. The two standard Unix desktop environments are called GNOME and Qt. Both have

Python support. There is similar support under Windows and MacOS.



There are plenty of command line programs written in Python. Some Unixes (e.g. OpenSUSE) have a helper program they call when the user asks for a command

the shell doesn't know. That helper program is written in Python.

Within programs there are support libraries for almost every purpose including a very

powerful scientific python library called "SciPy" ("Sigh-Pie") and an underlying numerical library called "NumPy".



Python is also used to control instruments (a simple robot is featured in the slide) and is also used in embedded systems. The card shown is ""...IEEE802.15.4 based, autoforming, multi-hop, instant-on, mesh network stack combined with an embedded Python interpreter for running application code."

synapse-

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download