Categories
Uncategorized

Python and Further Maths 1

Because of my numerical analysis background I am very passionate about teaching coding alongside mathematics. In particular, I don’t think the A Level syllabus really does justice to the numerical methods component of the course. As most real life problems have to be solved approximately I think that numerical methods are incredibly important, but that teaching them without coding them up is silly!

I have always found that once I have coded something my understanding of a method has vastly improved. Because of this, if there is time I think it is good to expose A Level mathematicians to a bit of programming.

Python is the ideal language for this as

  1. It is freely available across Windows, Mac OS X and Linux.
  2. The documentation is fantastic,
  3. The syntax is relatively straightforward.
  4. In it’s simplest form the Python interpreter can function as an advanced interactive calculator.
  5. It contains all the functionality of a modern professional program language (i.e. it is not just an academic curiosity)

I believe that number 4 in the above list is one of the big advantages of Python over a traditional compiled language (such as my favourite language Fortran or C++) as this can make the whole concept of learning a programming language for the first time a little bit less terrifying. For students, being able to see almost immediately what the commands they have just typed is very powerful – it must have been awful learning to program with punch cards!

For my first programming workshop with my Year 12 Further Mathematicians I chose to use the IDLE interpreter that comes with Python due to it’s simplicity.

  
With the Python Shell (the rightmost window in the above picture) you can type commands one-by-one and explore Python interactively. Launching the editor window you are able to write programs and then run them with the interpreter. One restriction of Idle with my school’s setup is that I cannot import my own modules – because of this for the next Workshop I will be using PyCharm. 

I gave my students a 6 sided worksheet, with some notes and examples to work through. See below for an example of the type of exercises and the full worksheet is here. 

 
All my students seemed to really enjoy doing a bit of coding, and I was really impressed with how well they got on. I’ve seen 2nd year undergraduates struggle more when they are introduced to Matlab than they were πŸ™‚ 

If you fancy having a go working through the sheet, the codes for the exercises are all contained in a tarball which you can download here.

I will write again about the future workshops.

2 replies on “Python and Further Maths 1”

Leave a Reply

Your email address will not be published. Required fields are marked *