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.
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!
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
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!