Introduction and Overview of the Compwiki Website

This page gives some background on the compwiki.physics instruction module and some guidance on how to approach the site.

Aims and Outline of the Site

The compwiki site aims to provide you, the "typical" physics major and specialist student, with the tools you need to start doing physics on a computer in general, and to learn the Python programming language in particular. Most of the material in the website is intended for first and second year physics students without previous experience or courses in programming with Python or any other computer language. This means that we will not here try to teach you how to become an expert programmer. Of course, high-quality programming skills are valuable, but we are here aiming for something else: to get you comfortable with working on computers for modelling and analyzing physical systems, and for working with data in the lab. We want these skills to become part of the toolkit you use every day to do work in physics. The computer codes we will ask you to write and work with will be relatively small, generally less than 100 lines long.

In computer programming, there is often a tradeoff between methods that are simple and methods that are highly efficient and accurate. We will typically highlight methods that are simple and easy to understand, rather than ones that are very efficient or very accurate. We will expect you to write your own simple codes, test them, and document them with comments and explanatory text. Understanding how to create efficient, accurate, well constructed, and reusable code is something you should aim for as you get more deeply into this subject. It is especially important as you start to work with others on larger programming projects.

Besides the foreword and this introduction, the website includes the following parts:

  • Installing Python shows you how to set up Python on your computer at home or your laptop.
  • The four part tutorial provides the main introductory material on the website.
    • Tutorial Part 1 covers some introductory Python and programming concepts like scripts, variables, and integrated development environments.
    • Tutorial Part 2 introduces functions and modules, with a focus on the numpy module.
    • Tutorial Part 3 introduces logical variables and statements, if blocks and while loops
    • Tutorial Part 4 (under construction) introduces lists, numpy arrays, and for loops.
  • Physics with VPython will help get you started with visual module of Python, for doing 3d simulations of physical systems. Lots of fun!
  • Physics with Pylab will help get you started with doing plotting and numerical analysis with Python.
  • Data Analysis with Pylab and Scipy will introduce you to using free Python packages for data analysis and visualization.
  • The Python Reference summarizes many of the main commands and concepts we want you to know for doing your Python related coursework.
  • Fun with Strings helps you learn how to manipulate strings, and provides insights into how Python works under the hood.
  • Numerical Integration focusses on important concepts in solving ordinary differential equations on the computer.
  • Functions and Modules provides an in depth look at how you can use and create your own code packages.
  • Questions and Solutions provide practice with the concepts we will cover in the website.


Suggested Study Path for 1st and 2nd Year Physics


History of the Site

The compwiki.physics instruction module is the result of several years of thinking about how to make sure that all graduates of majors and specialists physics programs at the University of Toronto have some competence in the use of computers to solve problems and do research in physics. Computer competency is not just a practical skill but an approach and way of thinking that can help bridge theory and experiment, and part of the everyday working life of the physical scientist.

This website serves as an introduction to the Python language and the style of programming that scientists employ when using Python. As we said in the foreword, we like Python because it is easy to start using interactively, because it is available free of charge, because it has a variety of applications and available packages, and because it is widely used in research and industry.

Computational instruction in physics at the University of Toronto is part of a broader physics curriculum renewal that began in 2008. This renewal includes several changes to lecture and lab courses that aim to consolidate and better coordinate them. We are working to make this material an integral part of the entire physics curriculum at the University of Toronto. As part of this renewal, we hope that this computational module will be useful in all your physics courses and will help you in courses and situations you encounter outside of physics.

Just as computing and applications evolve, so does the best way to document and teach them. So this website will always be a work in progress. We on experience and feedback from you, the users, to improve it.


This website has been very much a team effort, with contributions from faculty, graduate students, and undergraduate students.

  • Website committee (faculty of U of T physics): Paul Kushner, Ruxandra Serbanescu, Sabine Stanley, Charles Dyer
  • Working group on computational instruction (faculty of U of T physics): Website Committee plus David Bailey, Steven Butterworth, Jason Harlow, David Harrison, Stephen Julian, Qinya Liu, Stephen Morris.
  • Website design and setup: Paul Kushner, using online wiki software.
  • Foreword: Dyer
  • Introduction: Kushner and Serbanescu
  • Installing Python: Kushner
  • Tutorial Parts 1-4: Kushner, Serbanescu, Andrew Martin, Sergei Sagatov. Original inspiration for the tutorials came from several sources, including the VPython tutorial, Ray Pierrehumbert's Python tutorial, the Pylab tutorial, and A Byte of Python.
  • Tutorial exercise material: Martin, Sagatov, and Serbanescu created the various exercise sheets throughout the Tutorials, which will give you lots of practice.
  • Reference: Raphael Bouskila, Martin, and Sagatov.
  • Physics with Pylab: Kushner
  • Data Analysis with Pylab and Scipy: Serbanescu, Martin, Sagatov
  • Numerical Integration: Serbanescu, Sagatov, Martin
  • Functions and Modules: Serbanescu, Sagatov, Martin
  • Fun with Strings: Sagatov, Martin
  • Physics with VPython: Stanley


External sources gratefully acknowledged:
Prof. Roger Fearick, Department of Physics, University of Cape Town, South Africa (Python for Physics)
Profs. G. Daniell and J. Flynn: School of Physics and Astronomy, University of Southampton (Computing Module for PHYS2022)