Python Samples
Download the scripts listed below and run them from the command line on your laptop or on the lab machines.
- Basics: (read up on these examples in the Python Tutorial)
- Data structures:
- Classes:
- class1.py
- class2.py
- class3.py
- Bank account example
- Exercise: Go to the Python Online Tutor web page,
and do the introductory object-oriented programming exercises (OOP1, OOP2, OOP3). (These are very basic, beginner's exercises)
- Exercise: Implement a container class with methods for adding an element, extending with a list and a check for contains, and then implement a sub-class for a container that avoids adding duplicates (with the same methods). Start from this skeleton file containerNoDup_skel.py.
- Exercise: Implement the binary search tree example (from the basic C# exercises), with insert and search functions
- Advanced Language Features:
- Functional Programming in Python (see Functional Programming in Python by David Mertz):
- Advanced Language Features and Library Usage:
- Revision (see also simple_histo.py for a simple higher-order fct example):
Hans-Wolfgang Loidl
Last modified: Mon Nov 20 15:59:23 2017