If you want to work through a whole table of values, you're likely to want to store the values in a variable that can contain more that one value at a time. Python has fundamental data types of lists, tuples and dictionaries, and this module looks at lists and tuples.
This topic is presented on public course
Python Programming
Examples from our training material
| cmp.py | Comparing lists |
| inlist.py | The in operator - is a value in a list |
| lcopy.py | Copying a list (or rather - copying a reference to a list) |
| li1.py | List - first example |
| li2.py | for loop to handle each element of a list |
| li3.py | Use of range o give list indexes |
| li4.py | range to go through each element of a list |
| lister | 4 different ways of parsing a list |
| litu.py | Converting a list to a tuple |
| m2 | Alternative answer to exercise 1 |
| menu.py | A list of lists - works like a 2 D array but better ;-) |
| months | Answer - excercise 1 - day and month numbers |
| repeat.py | + and * operators on a list |
| revq | Parking exercise - mk 1 |
| revq2 | Parking exercise - mark 2 |
| revq3 | Parking exercise - final sample answer |
| sh2.py | Shuffle a list of numbers using supplied shuffle method |
| shuffle.py | Shuffle a list of numbers |
| slice.py | list slices |
| tu1.py | First use of a tuple |
Opentalk forum discussions related to this topic
shufflingCommon Python questions
Pictures
Python Training
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
Why do we have collections?.
Lists.
The for loop.
Alternative ways of processing members of a list.
Tuples.
Working with lists and tuples.
More ways to reference elements of a list or tuple.
copying a list.
Concatenating and repeating lists and tuples.
Comparing lists and the in operator.
converting to a list or tuple.
A real live program.
Lists of lists.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 600 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.