PYTHON PROGRAMMING

Site owner: Samy Zafrany

Python Programming Logo
"A programming language that doesn't change the way you think is not worth learning."
-- Alan Perlis, Epigrams on Programming

line separator

Quick Overviews

  1. An Incremental Introduction to Python
    Ralph Noack, University of Alabama at Birmingham
  2. Python Quick Tutorial
    Sven H. Chilton, University of California - Berkeley
  3. David M. Beazley - Advanced Python Programming
  4. Python Tutorials
    tutorialpoint.com
  5. Python's Class Development Toolkit
    Great video introduction to class development in Python

line separator

Advanced Tutorials

  1. Code Like a Pythonista: Idiomatic Python
    By David Goodger, licensed under a Creative Commons Attribution/Share-Alike (BY-SA) license
  2. Official Python Tutorial (www.python.org)
    By Guido Van Rossum
  3. MIT (Massachusettes Institute of Technology) Introduction to Computer Science based on Python
  4. Python Alternative Execution: Passcall Advanced Technologies

line separator

Free Books

  1. Think Python: How to Think Like a Computer Scientist
    Version 2.0.5, December 2012
    Allen Downey, Green Tea Press
  2. A byte of Python
    Free book by: Swaroop C H, 19 Aug 2013
  3. Dive Into Python
    Mark Pilgrim, Apress
  4. Fast Lane to Python: A quick, sensible route to the joys of Python coding
    Norm Matloff, University of California, Davis
  5. The Little Book of Semaphores
    Allen Downey, Green Tea Press

line separator

Links

  1. Python Programming Language - Official Website
  2. The Python Wiki
  3. ANACONDA - Enterprise-ready Python distribution for large-scale data processing, predictive analytics, and scientific computing.
  4. ENTHOUGHT - Scientific Computing Solutions
  5. 4542 Python Program Examples to learn from and use
  6. The Python Module of the Week - Many Cool examples for Pythons Standard Library Modules
  7. Bjarne Stroustrup: The 5 Programming Languages You Need to Know
    Bjarne Stroustrup is the inventor of C++
  8. Scripting: Higher Level Programming for the 21st Century
    John Ousterhout, IEEE Magazine, 1998
  9. Why did Google choose Python?
  10. 6 Lessons From Dropbox - One Million Files Saved Every 15 Minutes
  11. How Dropbox Did It and How Python Helped at PyCon 2011
  12. Guido Van Rossum: Python Creator Scripts Inside Google
  13. Strong versus Weak Typing A Conversation with Guido van Rossum
  14. Guido van Rossum on the History of Python (YouTube Video)
  15. NumPy
    A fundamental package for scientific computing with Python.
  16. SciPy
    An open-source software for mathematics, science, and engineering. The SciPy library depends on NumPy, which provides convenient and fast N-dimensional array manipulation. NumPy and SciPy are easy to use, but powerful enough to be depended upon by some of the world's leading scientists and engineers.
  17. David Beazly Youtube Channel
    Dave Beazly is a frequent conference presenter and tutorial instructor. Find videos and slides above.
  18. Python Programming Tutorial
  19. Monty Python's Flying Circus: Parrot Sketch

line separator

SOFTWARE

ANACONDA - Python Bundle for Desktop (Installer)

This is a large bundle that containse the core Python 2.7.5 system and a large collection of modules and packages. To be installed on a local disk of your desktop (or laptop).

Portable Python (for disconkey)

IDE's - Integrated Development Environments for Python

There are more than 40 Python integrated development environments, some of them are commercial and require usage license. We list here only 7 popular IDE's that we think are most suitable for our course. But most of the time we will use the PyScripter IDE and IPython console, but students are encouraged to also try PyDev or Microsoft PTVS extension (requires Visual Studio license).

EDITORS

In many circumstances it is preferable to write Python scripts on a simple text editor that supports Python syntax highlighting and name completions. Here are two popular choices:

PyCmd.exe

PyCmd is a smart command prompt extension for Windows' cmd.exe; its purpose is to emulate a few power features of UNIX shells (decent Tab-completion, persistent history, etc.) It is best combined with Console2: http://www.hanselman.com/blog/Console2ABetterWindowsCommandPrompt.aspx

Python Modules

Following is a list of Python modules that we may need for this and other college courses. Most of them are already included in ANACONDA or Portable-Python, so you do not have to install them (just know about their existence). However, those packages that are not included in ANACONDA or Portable-Python, must be installed twice: once for the portable Python installation, and second time for the desktop Python installation. If you plan to work on the Desktop Python only, then you can ignore the portable option.

line separator

Installing New Modules - HOW?

If you have installed the Anaconda bundle then you probably have all modules and packages that you need and most likely that you will not have to install anything else. However, as a fast evolving language, new Python modules are released and updated frequently. So you may need to install or update a module once in a while.

Most modules for Windows are self-extracting msi or exe files that automatically install to the default library directories. There are however some modules that are not of this type and need to be installed manually (usually from the DOS console).

  1. The most recommended method is to use the pip command from the DOS console. If needed you can access this command by its full path from:
    • ANACONDA: C:\Anaconda\Scripts\pip.exe
    • Portable-Python: App\lib\site-packages\pip.exe
    The pip command takes a module name as an argument and then search for it at the internet and installs it. So you need not download anything at all. Here are a few examples:
    • pip install pywin32
      Installs the pywin32 module to the default library
    • pip install --upgrade pywin32
      Upgrades the pywin32 module
    • pip install -t F:\Portable-Python\App\lib\site-packages psutil
      Install the psutil module into the Portable-Python library
    • pip list
      List the currently installed modules
    • pip help
      Print help on all available pip commands
  2. c:\Anaconda\Scripts\easy_install.bat
    This is similar to pip, but should be avoided unless pip fails to do the job.
  3. If pip and easy_install methods do not work for you, then you must download the module, unzip it, and run its setup.py program manually.
    • Download your new_module and extract it to a temporary directory: "C:\TEMP\new_module"
    • Open a cmd.exe console
    • Go inside that folder: "CD C:\TEMP\new_module"
      You should find there a python setup program: "setup.py"
    • To install to the standard Python, run the command:
      "setup.py install"
    • To install to your Portable Python flash drive, use a command like:
      "x:\Portable Python 2.7.5.1\App\python.exe" setup.py install --prefix="x:\Portable Python 2.7.5.1\App"
      Make sure to replace "x:" with the volume name of your flash drive.

line separator

COURSE PROJECTS


Project 1

Introduction to the Python programming language

Solutions

It is the student responsibility to do anything he can to solve these problems before reading the solutions. Just by reading and understanding the solutions is not enough for gaining programming expertise.

Project 2

Project 3

Project 3 Solutions

To make it simple, downloa all solutions file (with graphics files) from: PROJ3_solutions.zip

EXTRA PROBLEMS

Some more challenging algorithmic problems that are great for practice towards final examinations and major course projects. You are encouraged to try as many as possible of them in order to learn how to program - this is the only way to gain programming experience and expertise!!! The solutions of these are currently not available, but we may provide solutions to some of them at the end of the semester.

line separator

Kernighan's Law: Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!