What's this?
This is intended to be a collection of exercises, sample programs, and links to help
programmers who know Java, C, C++, or some some similar language get started
programming in Python.
Setting up
If you don't have Python installed already, try these
brief installation
instructions.
Sample programs
Read and experiment with these programs to learn some of the basics.
The basics
- basics.py
- Arithmetic, strings, conditionals, while loops, and boolean expressions.
- lists.py
- Lists and tuples.
- commandline.py
- Using command-line arguments.
- files.py
- File I/O, command-line arguments, and exceptions.
- functions.py
- Functions.
- classes.py
- Classes.
- dictionaries.py
- Dictionaries (a.k.a. associative arrays, hash tables, etc.).
More advanced samples
- listsorting.py
- Sorting lists.
- dictionarysorting.py
- Sorting dictionaries.
- directories.py
- Traversing a directory tree.
- getPageFromURL.py
- Using the urllib2 module to retrieve a web page.
- regex.py
- A few simple examples using regular expressions and the re module.
- cookies.py
- How to use cookies in HTTP server-side programs.