Python

This page provides basic walkthroughs and tutorials for the programing language Python.

We do not cover all aspects of programming in Python. We provide some starting points and expect you find more. We recommend [Wentworth2012] as your main teaching material. The more advanced book [Pilgrim2009] may perhaps be more interesting for experienced programmers

PyCharm

Integrated Development Environment (IDE)

Pro version:

  1. log in by using your faculty email https://account.jetbrains.com/login
  2. then you may download https://www.jetbrains.com/student/

For us, Community Edition is actually quite fine https://www.jetbrains.com/pycharm/download/

We actually need none. So if you are used to work in Emacs, Vim, … and terminal/shell yust keep doing.

Installing Python

If you are using Linux, Python is most likely already installed. Otherwise, install it using your SW manager (like Synaptic). Python is also quite likely to be already installed in Mac OS X. Try running terminal and write which python. In the case of MS Windows, it will not be installed. You will have to install it.

In a terminal window (Linux or OSX) you can check:

[182] python3.2
Python 3.2.2 (default, Mar 15 2012, 17:46:27) 
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

[53] python3
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

You can quit by Ctrl-d, or typing exit()

We will use the 3.4.x version. Please be aware that on many machines Python 2.7.x is still often the default Python interepreter. Python 3 is not fully compatible with Python 2.x. There is a code converter which makes the possible transition easier. Many important libraries have been already ported to Python 3.

Literature and other resources

For Python, there are many freely available online documents and books. Use them, google them, find your own. We expect that experienced programmers will find their way. For beginners we have few recommendations:

  • Python for Software Design, How to think like a computer scientist [Downey2009]. Non-traditional and interesting book, easy to read. Helpful especially for someone with no or very little previous programming experience. Updated (to Python3) version is [Wentworth2012].
  • *Dive Into Python, [Pilgrim2009] is rather for advanced programmers.
  • Python Style Guide. How to name modules, variables, classes and functions, how to write comments and so on.
  • Python Debugger is nice introduction into Python debugging for beginners.
  • An Introduction to Tkinter overview of the Tkinter - library for GUI and graphical output. We will not use it but you may want to play.

Watching and listening

  • Online courses (including videolectures) of fundaments of programming can be found e.g. at Coursera.org. Although the courses may not be currently taught, it should be possible to watch the videolectures in the course archives. We can suggest the following courses:

Other walkthroughs

  • MS Windows quick guide for setting up your IDE (DrPython or IDLE) under MS Windows.
  • Work with files quick introduction to working with File Systems in Python.
  • faq Problems which, according to our experience are quite common. We continuously update the list.
courses/be5b33prg/tutorials/python.txt · Last modified: 2018/08/13 09:48 (external edit)