X Close

Research IT Services Blog

Home

Technology and services to support your research

Menu

The Python’s Tale

By Tom Couch, on 17 December 2013

Being able to write a computer program is an incredibly useful skill for anyone to have and more and more researchers are finding that they need to learn at least the basics in order understand how their data is being treated. There are a lot of courses freely available online, where people can learn pretty much any language they want at their own pace, though obviously some are better than others. I’ve tried three online python courses and written about them here as a guide for anyone who is considering learning to program.

I decided to learn a new programming language, not just so that I could write my own software, but also to improve my knowledge of how computers work in general. Before embarking on my quest to learn python my prior experience of programming was pretty much limited to writing VBA macros in Excel. This meant that I was familiar with most of the basic concepts involved in programming such as variables, data types, conditional statements and loops, but I was a long way from being able to write my own standalone scripts.

After taking advice from friends and colleagues, I decided to make Python my first proper programming language because I was assured that it is relatively easy to learn and it’s also popular with scientists. My first Python course was recommended to me by James Hetherington from RITS’ Research Software Development Team and was called ‘How to think like a computer scientist’, which I thought was a pretty impressive sounding title.

This course has been updated since I did it earlier this year and now seems to have even more interactive widgets to play with as you learn about python. I don’t think the content has changed too much though as the online course is based on a book by Jeffrey Elkner, Allen B. Downey, and Chris Meyers. One of the things that really impressed me about this course was how well written it is, with clear explanations, well-paced development, and regular multiple choice tests and coding challenges interspersed throughout chapters to test and reinforce what’s been learned. Exercises at the end of each chapter then give students the opportunity to put everything they’ve learned together in order to solve some harder problems, some of which were quite tricky. What’s particularly good are the embedded tools such as the ActiveCode windows which allow students to write and run code in the web browser, and CodeLens which shows how programs operate on a line by line basis and how variables are used and modified at each step.

The course makes fairly frequent use of the Python Turtle module (See Figure 1) to explain many of the concepts covered in the course such as loops, use of modules, lists and L-systems which worked well for me as I quite enjoyed the pretty pictures you could get the turtle to draw (I even wrote a program that draws a unique tree every time you run it). The course’s title is probably a little overambitious as I didn’t feel like a computer scientist by the end, but I found this to be a very engaging and informative course. The one area where I thought that this course fell short in relation to others is the limited amount of time spent describing working with objects which is only introduced in the final chapter. Having said that, this course covers a lot more material than any of the other courses I have tried since.

Figure 1: The turtle vector graphics module in action on the 'How to think like a computer scientist site'

Figure 1: The turtle vector graphics module in action on the ‘How to think like a computer scientist site’

The second course I tried was Google’s Python Class. In contrast to the other two Python courses I’ve tried, this one did not use any online code editors or tools and instead began by providing users with instructions on how to install python and a suitable editing package. I actually prefer this approach over the use of browser based code windows as I think that setting up the working environment is an essential part of learning to be a programmer.

Although this is probably the shortest of the three courses, they manage to pack a lot of material into that space, including several topics that neither of the other two covered: regular expressions, file system interaction, and HTTP requests, all of which I can see as being useful to anyone intending to write their own software. Lecture videos also accompany each module, providing an extra visual demonstration for those who want it. Personally I found that this wasn’t really necessary though.

The course also provides challenging but imaginative exercises which allowed me to practice what I had learned. One exercise, for example, involves writing a script that can search a file for URLs, download parts of an image from these URLs and then piece them together in the correct order to show the completed scene. The instructions for these exercises provided just enough direction to get me started whilst also demanding that I really think hard about how to use what I had learned in order to solve each problem. Fortunately the scripts also came with solutions for when I got stuck or wanted to see if my solution was the same as theirs.

Overall I’d say that this is probably not the best course to start with because the pace is quite fast, but there is a lot of useful information here and it was a good way to consolidate and expand upon what I’d learned in the previous course.

The third and final online Python course I tried was from Codecademy, which provides a range of courses for different programming languages on the site. The ethos of this site is of a social community of users and you have to sign up for an account before you can start which allows them to track your progress and provides access to user forums. The course is broken up into a series of modules which introduce the usual python concepts in much the same way as other courses. The pace of these modules is fairly slow though and it can be a bit frustrating sometimes having to go over old ground. Codecademy awards users with medals for achievements such as completing modules or visiting the site for several days on the run, which some people might find childish but it worked on me and kept me interested.

The exercises at the end of each module were a bit of a let-down though as they were pretty unimaginative, and users are guided through in such small steps that they weren’t really challenging. Each section links to a user forum where help is available if you run into problems but this wasn’t really necessary. You are encouraged to get a bit more creative towards the end of the course and share your results with other users so perhaps that might appeal to some people.

On the plus side, I found that this course offered the best explanation of object orientated programming and it was also the only course to discuss bitwise operations. Once you’ve signed up for an account you’ll also have access to a lot of other useful courses covering topics such as Ruby, PHP, HTTP and CSS, and javascript.

On the whole I think that this would make a good introductory course for someone who is new to programming, but not for someone who already knows a fair amount about programming in another language.

Overall I’d recommend that anyone who is learning to program from online courses should try at least two. No course will teach you everything you need to know, but you may find that one course’s explanation of a difficult concept is much easier to grasp than another course’s, and that this situation is reversed for other elements. No course or combination of courses can substitute for practical experience, and for this reason it’s also really important to at least have an idea in your mind of a project you would like to apply these skills to. Try to build up your idea for the project as you go along and as you go through the courses you can be thinking about how you would use the methods being taught in your own project. This will help you to see the wider potential outside of the examples given in the course. Finally, when you finish the courses, keep the ball rolling by programming a little and often, even if just for the sake of it. It might be fun.

Leave a Reply