You are here: mathematics > Vedran Šego > Teaching

# Teaching

## Programming with Python (MATH20622)

`yzYYJyY[iFr
~  ,`   {!
` {Ako{i{{{{JcC%`
!\  + ++++  L
`CA[{CEkPPYYA)AE `
ml{!{    {{ +g
,MC  )GAAAAAAAAA
%W  +W)!)"):"sU
'IA!,&AACEAAAA@A
`@w   WU%&OOOONw
` `AAAACAAAAAA%GAG
.GIaJWeGU@wMN@CW
%
`    `BAmCAA&AGEEA%mA
" d!! aWWWBN@m
`!+'![)!\!)\N@EAA%WC````,
;'  ` `   NWBMN@W ...
. .
` zAAuukYYIK%CAEA%AAA@C`y!){{`
c'   +{\  {:iMNBNNNm, . !
.
yA)<[iY)kC%ACAAAAGGEEA`f~'`z{
'C+ ; `+ ; :dcgBMWWW@C~  ,~
%
`A%YCACACAACKGEEMACAA%A`o)))[P`
,GN{O)hi&VO%&WWWsOmIENY,    (
.K                     .
AAECCAGAACEACAAAAAEEAAA,kyr?CC!
G@WmUW@mWMVmIZguySiama.     L
%
Am%AAEMEAAAECCMWmCwAEAK`sifyIIr
s@NBm%s&esJiZZ   { )RN ,    '\
.
EMAEMECAAB@WWWWBAAWACA`izLLizI[
%%@%s%Wec       \\ fWZ.      *{
EAKEKKAAEACAAA&&mmACC;{Yr[[?cII
Ww&%&&OsiyZ!!:    \dL '  ;;  ;'
AGKKAKEAAc``~,,,~~```{\,r[[?cFF
@W&&m&MCo ~~ ...  ,,,  . ;;
...
EAKAGGMC!`z'!!!!+![)!"`[f[fiY)i
%@&mWWs%., +`  ` .  ` ,  ;   +!
.          . .
CAEKAAGY'Y!,```'*!''+'<LLfi{cyc
&B%&mm@+ {`.,,~,  ;; ;     + '
. ..       ,
&AAAEAA*?J!!'\!)<{{{{[LL?i{YYu'
NOGMUw    '; `   '.!(    + ` +
, .
YEAAAAA`f['{![rr[[[[r[[Lf[[?Yu,
,WoclZV, .+.~.  (.(( ;;  ;( , .
.
'AAAAAA`{[[[LL[{<<jj<{''{)!{FY
`Zo:!Ju,'.(;  .'      ++  `!
.                  .
LEACAC~jr[[[!{)!++!+'''\!)?y~
Mcdi&   (;(~' .  ' ;;; .  '
,,,
<RAWN`<[r[{[!['"""``!'[<{[`
\  . ; .'.~ ;   ::`;  !(,
,    .
`{Lr{'[{!,,,`,,` ```
!  '+.+`.......
.
`    `[f[{'[J{[[!j!\<`
. ('+( .  ` `
. .
`{[{{{[yc?[[[{'L`
!;!'..   ;; !+
`{{[[j'[J[y! ,)I`
'    +( {'` .+'
`{!`!!!!{i), `C[
`: `'.! +.  ';
.
~'!```!!{Yy!Yu'
+`:::`..  '  `
,\!'!!+){JIi'
. .;''  ! ' `
,
`,!!))[!"'
. .   .

Lectures: Alan Turing building, G.207, Thursday 11-12
Lab classes: Alan Turing building, G.105, Friday 9-11
Office hours: Alan Turing building, 1.218, Thursday 12-13

Install Anaconda on your Windows machine: PDF
Linux and Mac users can install Anaconda in a similar fashion, or they can install the repository provided Python 3 (with Spyder or some other editor included).

Fun fact: There is an easy way to pretend that you are programming (in C, not Python).

Notes:

• To download IPYNB files, right-click them and use the "save" option (the exact name of the option depends on your choice of browser).
• The exercises are meant to be solved at home, prior to lab classes. Lab classes problems are meant to be solved by students during the lab classes (and finished at home), but you are welcome to try them at home as well.
• The standard form for the name of the solution files is "name-xx-yy.py". Those files that have additional parts in their names are aimed at the students interested in more advanced programming, usually incorporating more than what is covered by the materials so far, and – as such – will not be part of that week's tests.
For example, the files named in the form "name-xx-yy-py.py" are so called "Pythonic solutions" that use more advanced Python constructs (some of which will be covered in the later lectures).
Each solution has a short description in its docstring, emphasising when it is not a "standard" solution.

Week 1: Introductions

• Lecture: The course introduction [PDF]
• Lab class: Python introduction, input/output, variables, operators [HTML, IPYNB]

Week 2: Loops and conditionals

Week 3: Functions

Week 4: Lists and other iterables

Week 5: Strings, generators, and generator expressions

Week 6: Control flow

Week 7: Modules

Week 8: Files I/O

The coursework [HTML, IPYNB]

• The deadline is 23:59 on Friday, 8th May.
• Anyone getting encoding errors when parsing the currencies file, use this URL instead.
• To submit your solutions, zip your 6 programs and the module in a single .zip file and upload it. Do not include any other files.
• The coursework feedback (currently unavailable)

Note: The new materials below (from the 9th week to the end of the semester) will not be part of any examinations. Furthermore, there will be no lab classes in the last two weeks (but the materials will be available for all the interested students).

Week 9: Analysis of algorithms

Week 10: Data analysis

Week 11: Graphs

Week 12: PIL - Python Imaging Library

### Extras

Here are some Python programs that I have created either for fun or to automate a specific task. All of these use modules and concepts beyond those covered in the regular course materials, aiming at those students who want to learn a bit more.

 PyVer A simple program that prints the version of Python and some of its commonly used libraries (SciPy, NumPy, Matplotlib). PyteArt A collection of generators of ASCII art with overlapping characters, used to produce the "image" above. The project was created as a result of Nick Higham's challenge to make a port of his typeart program to a more modern setting. His original motivation and source code are available here. The main difference from the usual ASCII art is that we allow overlapping characters. While that impairs with display options (usually, ASCII art can be viewed as an ordinary text file, or - at least - in a console, if colouring is required), this approach allows better representation of the image's pixels. Pardoner's puzzle A recursive program that solves the Pardoner's puzzle fairly quickly. The input data is built in the code itself, but it is easy to change to solve any similar puzzle. Pic-in-pic An example of image manipulation which shrinks the image and pastes it over or under itself as many times as needed for it to fade away. PackSols A simple, yet very configurable program to pack the solutions of the exercises, lab classes, and test into zip files that I use before uploading them to the web. Knight on Board A recursive program that finds one possible way for a knight (a chess piece) to visit all the fields on a board.

## My previous teaching appointments

The details can be found in my CV.