Introduction

This text will be an introduction to the use of Python and git for students of mathematics at Lund University. No prior knowledge in python or git will be assumed by the readers of this text. The only thing assumed is some google skills and a passing familiarity with ones own operating system, be it Linux, OSX, Windows or another one of your choice.

Installing Python

I assume that you read this text on github or somewhere similar where ipython notebooks (we'll come back to this in a second) can be displayed without having python installed. To run the code in this notebook you need a working copy of python and ipython installed. We'll begin by describing the process for Ubuntu. If you have another distro just repace apt-get with your packet manager.

Ubuntu

If you use Ubuntu, python should already be installed. You can check this by typing

python --version

and if you get 2.7.x you should be fine. If you get an error message that you don't have Python installed, just type

sudo apt-get install python

You also need ipython installed. To check if it is installed, type

ipython --version

and if you get 3.x you have a recent enough edition. if not, just install it with

sudo pip install ipython

if you have pip installed (called python-pip in the repositories) and you now have a working copy of ipython.

Windows

To install python on windows, go to the homepage of Python and go tho the downloads section. Choose Windows and the current version of the 2.x series (this is the one used by later courses in numerical analysis) and download it. If you have a 64 processor then choose the Windows x86-64 MSI installer, if you don't or don't know, choose the Windows x86 MSI installer. Run the installer to get the latest version of python installed. Check that you have installed python by opening your command prompt (open your start menu and search for 'command') and write python. If you have python installed you will be in the command prompt of python. To check your current python version, you'll write your first python code:


In [2]:
import sys
sys.version

And you will get your current version. Make sure that it is 2.7.9 or higher. Then you will have pip installed automatically and your work will be reduced substantially. When you have seen your current version, close python by closing down the window. You now need to use pip in windows to install iptyhon. Do this by typing

python -m pip install ipython

in your command prompt (open your start menu and search for 'command'). You now have a working copy of ipython installed on your system. Another option is to install a scientific package containing python and all the mathematical libraries you might need. One such package is pythonxy.

Installing git

Git is a revision control system. This means that it keeps track of changes on your files and directories. For example, if you have the following directory tree

awesome_project/
    super_code/
        function.py
        wharez.py
    README.txt
    main.py

then if you thell git that this is a git repository then git will keep track of the changes in these files and their movement within this project.

Ubuntu

Installing git in Ubuntu is as easy as

sudo apt-get install git

and you're done. Make sure that you have the git gui installed if you prefer not to use the command line. This is can be done by typing

git gui

in the terminal. If it's not installed, you can install it with

sudo apt-get install git-gui

Windows

To install git on Windows, go to the git homepage and head over to the downloads section. Download and install git and the native git gui (graphical user interface) should be included. If you prefer another one, there is a large selection of gui's on their webpage.

downloading this notebook

To download this notebook using git the only thing you have to do is clone the repository from github. You can do this by typing

git clone https://github.com/rorimac/Tools-of-a-Math-Student.git

in your terminal while in the directory you wish it to appear. If you prefer to use the gui, just start it (from the start menu or typing git gui in the command prompt) and choosing

clone existing repository

and writing

https://github.com/rorimac/Tools-of-a-Math-Student.git

in the source location and choosing the directory you want it to appear in.

Using the notebook

Start the ipython notebook and go to the directory where you have stored this notebook. Open the Chapter1 file and you will be able to read this locally in the browser. If you wish to run the code in the notebook you can select the cell and press shift+enter and the code will run. You can also change the code or write your own as you go along.