[Tutor] forum

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Mar 30 13:09:21 EST 2004



On Tue, 30 Mar 2004, Lum Sau Fong wrote:

> 1.  no doubt Python appears to be a programming language which uses
> "normal" English language, instructions on its usage is still too
> technical for a beginner.

Hi Lum Sau Fong,


Some of the tutorials are targeted toward people who have already
programmed in another language.  You may want to look at:

    http://www.python.org/topics/learn/non-prog.html

The tutorials on that page are a bit more gentler than the official Python
Tutorial, and you might like them more.



Programming languages are superficially "English" since they use English
keywords, but it's not really English at all!.  Be careful, because there
are some places where English usage and Python programming usage will
collide.


One notorious example of this is:

    if x == 5 or 6 or 7:
        ...

This is syntactically valid, but has a very different effect in Python
than in English.  Python does not check to see if x is equal to 5, 6, or
7, but instead does something very different.


To get the effect we want, we should say, instead:

    if x in (5, 6, 7):
        ...

which asks Python, "Is 'x' one of the following elements?"




> 3.  it has been fun using Python, and it is exciting when the simple
> programme worked!

That's great!


If you have questions, please feel free to ask.  Good luck!




More information about the Tutor mailing list