What am I working on?


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:
$ python

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:

less!

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:

less!

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?

selsine

del.icio.us del.icio.us

6 Responses to “What am I working on?”

  1. import this. » Blog Archive » Another Python neophyte
    Says:

    [...] Learning Python tracks the progress of a Python newb’s quest learn Python. Ony three posts so far, but I’m sure there will be good things coming in the future. [...]

  2. selsine

    selsine
    Says:

    Hey thanks for the post about my site. It’s in it’s very early stages write now, but I hope to add much much more to it as I learn python.

    I’ll also add some person information soon, so I’ll be less anonymous on the site!

    I gave your top 10 list a read it’s got some good information and I’ll be sure to use it.

  3. Steve L
    Says:

    Hi,

    Just wanted to let you know that I recently started using python. I think it’s going to be a great language to use as the swiss army knife. The REPL is invaluable for programming for exploration and it’s been helping me with my school projects (though it took a while to get handy with).

    If you haven’t already, go check out ipython (http://ipython.scipy.org/) .. makes the interactive shell more functional … really useful.

    Good luck on your new adventure .. I’ll be checking in every now and again to see how it’s going :-)

    -steve

  4. selsine

    selsine
    Says:

    Hey Steve,

    Thanks for the information, ipython looks pretty cool I’ll have to give it a try when I get more time. Hopefully that will be soon, I’m excited to try out a new language.

  5. learning python » Blog Archive » Writing my first python script
    Says:

    [...] Well after reading the python documentation for a few days I decided it was time for me to write my first real script. Now I’ve written a few scripts before in the python interpreter, but I wanted to try my hand at creating some stand-alone executable file. [...]

  6. hasardspel groups on the internet
    Says:

    hasardspel groups on the internet…

    razor:subsets establishing vandalized.Reuters Kinshasha,…

Leave a Reply

 

Popular Posts