Taking on Python with Codecademy

Since I last visited Codecademy, tutorials have been added for another programming language – Python. Dubbed as the language of choice for beginners and experts alike, the Python tutorials enticed me into learning how to create interactive applications.

The introductory tutorial, Python Syntax, sets out to introduce coding novices like myself to Python. With module titles including words such as variables, statements and comments, it looks very similar to JavaScript. Like Java, Python is an object-orientated language and is used for applications, web and game development.

What I really wanted to know was where the name came from but it turns out that Python actually has nothing to do with snakes. The name is in fact derived from the television series Monty Python’s Flying Circus. This reflects the important goal of the Python developers – to make Python fun to use. Sounds good to me, let’s give this a go!

Python variables appear to be simpler than those in JavaScript. Rather than having to declare the variable and then define its value (var variable = 10), entering variable = 10 is sufficient to declare and define a variable.

Three data types were introduced for use with variables – integers, floats and booleans. Floats and booleans could be another Monty Python reference for all I know, but for this purpose floats are fractional numbers written as decimals and booleans can be True or False.

Variables and data types are the building blocks that form statements. In JavaScript, statements are separated with a semicolon while in Python statements are separated by whitespace. Empty lines are a form of punctuation in Python and have to be used carefully. Errors also appear if the code is not properly indented, as I found out the hard way.

Comments always start with # (hash symbol) and are written in plain English – that’s my kind of code! They provide instructions or explain how a particular part of the program works. For multi-line comments, triple quotation marks are used to avoid having to add a hash to every line.

Variables can also be set as mathematical expressions using arithmetic operators such as addition (+), exponentiation (**) and modulo (%). I was given the task of setting the variable eggs to 100 using exponentiation, it took me an embarrassingly long time to realise this just meant 10 squared or 10 ** 2. Perhaps I should revisit GCSE maths before learning to code!

Fortunately Codecademy didn’t notice my long pause and awarded me another achievement badge for completing Python Syntax. Though I may not be a proficient coder just yet, I’ve certainly had a taste of my fair share of languages. Now I’ve started JavaScript, HTML and Python the question is which course to complete first?