Saturday, 19 March 2011

An introduction to Python

Now, I am by no means adept at python; far from it in fact. I have attempted to learn many programming languages several times, all end within a couple of days and finish up with me not wanting to touch another programming language again. But I got to thinking, I need to regularly update my blog and need ideas on what to do each post on. So I thought, I will update as a go along with mini lessons that should hopefully inspire and help people who are first beginning to code in Python.

Why Python first of all? Well, it is one of the simpler first languages to learn that is actually used by large corporations (one of the most notable are Walt Disney). It isn't exactly too complex to begin with and has a steady difficulty curve. And an added bonus? It's very mathematical!

The first thing you need to do really is download Python. The current version (as of 19th March 2011) is 3.2, but the majority of what I will discuss is from the 2.x versions, however they are not too different and the 3.x versions is basically just cleaned up from 2.x versions. However 2.x has a far greater library support, meaning custom variables that other people have created are much more readily available.

Download Python here. Another download that you may want is Notepad++ the amount of languages it recognises is pretty phenomenal; from HTML to Python and everything in between. If you'd like this brilliant open source software go here.

Once you've downloaded all of these we'll start you off with your first lesson. I will begin by introducing probably the most important command in Python, it's incredibly simple but is used to display any text.

"Hello world!" is the absolute must as it goes for starter programs, so that's what we'll do.
print "Hello world!"
When the program is ran it shows:
Hello world! 
 And that's it. Things to take note of are; the print command and the quotes. Any string of text has to have quotes surrounding it, else it does not make sense. And the print command has to come before any text you want to be "printed". And that's it for now, but the next lesson will be far more technical.

No comments:

Post a Comment