(Vincent Delecroix, LaBRI, Bordeaux, France)
This github repository contains material used to teach Python at AIMS Rwanda in fall 2016. You can also find complementary information on AIMS Rwanda website.
At the bottom of this page you can find a list of references and some tips for the jupyter notebook.
To download a document right click on a link and chose "Save link as".
- Jupyter worksheet 1 basic Python and plotting
- The second worksheet has been split into two parts
- Jupyter worksheet 2.1 lists and for loops
- Jupyter worksheet 2.2 conditionals
- (you can still access the Old Jupyter worksheet 2)
You can also download this demo about Fibonacci numbers
- Jupyter worksheet 3 (assignment) functions. This worksheet is the subject of the first assignment that has to be sent before monday 9pm. To submit your assignment go to the Jupyter menu and download the worksheet in ipynb format ("File -> Download as -> Notebook (.ipynb)"). Then send this file by mail to the tutors. Do not forget to write your name in the worksheet! You are free to ask as many questions as you want to me or the tutors.
- Jupyter worksheet 4 probability.
- correction part 1: correction of the parts "Plotting discrete probability measures" and "Plotting continuous probability measure".
- correction part 2: correction of the parts "Sampling"
- Jupyter worksheet 5: file input and output.
Starting from thursday and up to the end of the course, there will be a quick questions/answers each morning (10min time). A sheet of paper will be distributed to each of you with a list of commands. You will have to write down what would be the output of these commands when run in a Jupyter Notebook. You have to answer without using a computer of course. The material of the two tests of week 2 are contained in worksheet 1, worksheet 2.1 and workheet 2.2.
The assignment (to be submitted before saturday 11:59:59pm) consists in programming in a Jupyter worksheet:
- a function
digits(n, b)
that returns the list of digits ofn
in baseb
- a function
prime_range(n)
that returns the list of the prime numbers smaller thann
- a function
is_prime(n)
that returnsTrue
ifn
is prime andFalse
otherwise - a function
gcd(x, y)
that computes the greatest common divisor ofx
andy
- solving various problems from Project Euler with at least:
A solution for the arithmetic function can be found here in pdf format.
You can also download this demo about timings of the is_prime function
The program will be confirmed. In each course, there will be 1h dedicated to learning a new Python technique and 1h for your research project (see below).
New Python techniques to be learned:
- recursion (end of worksheet 3)
- Jupyter worksheet 6: slicing
- Jupyter exercises on for loops: exercises on for loops
For the assignment you will have research projects in group. Each group will be made of 3 or 4 students (the constitution will be given on friday evening of week 2). During the week-end, each group will have to chose three subjects by order of preference and submit their choices to the tutors before sunday 7pm. The final decision of project allocation will be made for monday morning.
I compiled all remarks about oral and writing in Remarks about assignment 3 (pdf document).
Beyond the material available in this repository, you might want to consult:
- The "Help" menu available in each Jupyter worksheet
- Python 3 documentation: contains among others a tutorial and a complete description of the standard Python library
- Scipy lectures: Python tutorial in 3 sections starting from learning Python up to using advanced features of scipy and pandas
- Scipy website: information about the SciPY stack. Contains links to other resources.
- Project Euler: more than 500 exercises that have to be solved with a computer
- IPython tutorial: tutorial about IPython
-
To start the Jupyter notebook:
- open a terminal
- run the command
jupyter notebook
-
To stop the Jupyter notebook
- for each open worksheet, go to the menu and do "File -> Save and Checkpoint" (in order to save your work) and then "File -> Close and Halt"
- go in the terminal where you launched the notebook and press
Ctrl-C
right after you need to pressy
andEnter
(you have 5 seconds to do this second step)
-
(for AIMS computers) in order to see the
matplotlib
images embedded in the browser you need to execute the following line in a code cell%matplotlib inline
Copyright (C) 2016 Vincent Delecroix [email protected]
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC-SA 4.0). This license allows you to reuse this material at your convenience but:
- it can not be used as part of a commercial activity
- you need to specify the original author and sources
You can either read the Creative Commons Deed (Summary) or the Legal Code (Full licence).