Well first things first I guess lets talk about what sort of computer(s) I will be using to learn python. I will be using two different computers for the most part, with the chance of their being a third in their at some point.
Both computers are running Linux, one running ubuntu and the other (my Xbox) running Xebian. One thing you’ll notice is that both distributions that I use are Debian based, this is simply because I’m a big fan of apt-get as a package management solution.
Neither of they computers are all that new or all that quick, but I think that they’ll get the job done.
To start off I’ve been reading a python tutorial, it’s pretty good and it giving me a good introduction. The first thing I did was file up the python interpreter by starting a terminal and typing:
Note: The $ represents the start of the command prompt, so I only typed the word ‘python’.
Here’s a quick tip about the python interpreter, if you want to quit try CTRL+Z or CTRL+d. I swear it took me forever to figure out how to exit the interpreter.
Here’s the first little bit of python that I typed into the interpreter:
>>> mark = 5
>>> if mark < 10: ... print 'less!' ...
And the result:
For those of you unfamiliar with the python interpreter when it is in “interactive mode” it will basically interpret whatever you type as you type it. So the first line I typed:
>>> mark = 5
Assigns the value 5 to the variable mark, not that difficult if you’ve ever programmed before. You’ll also notice the >>> that start the line those this is referred to as the primary prompt, and basically means that this current line is not reliant on any previous line.
You can see the difference in the next two lines:
>>> if mark < 10: ... print 'less!'
Which basically means if the variable mark is less then the value 10, print out 'less!' Since the if statement needs more lines of code before the if block is done, the next line starts with '...' which means that it's a continuation line.
You'll also notice that there is a tab before 'print less!', this is because in python white space has meaning. So instead of using a begin or an end tag, the white space delimits the code block. This is actually one of the features that I like the least about python, apparently one gets used to it, so I'll try not to complain about it.
After that there is is another line with continuation line starting with '...', that's basically the interpreter tying to figure out if the if block is going to continue. On that line I just hit enter, telling the interpreter that the block is done. Then the interpreter evaluated the if statement, and found out that mark was indeed less then 10 and so it printed out the results:
Well I’ll have to cut this post short, I was supposed to be somewhere 15 minutes ago, darn computers. What do you think they’ll say when I blame it on python?