[perl-python] 20050115, for statement

Discussion in 'Python' started by Xah Lee, Jan 15, 2005.

  1. Xah Lee

    Xah Lee Guest

    © # this is an example of for statement
    © # the % symbol calculates the remainder
    © # of division.
    © # the range(m,n) function
    © # gives a list from m to n-1.
    ©
    © a = range(1,51)
    © for x in a:
    © if x % 2 == 0:
    © print x, 'even'
    ©
    © # note that in this example, for goes over a list.
    © # each time making x the value of the element.
    ©
    © ------------------------------------
    © # this is similar code in perl
    ©
    © @a=(1..50);
    © for $x (@a) {
    © if ( $x%2 ==0){
    © print $x, " even\n";
    © }}
    ©
    © # PS each daily tip can be run. Just
    © # copy the python part and save to a
    © # file and run it as "python
    © # file.py". Try it.
    ©
    ©
    © Note: this post is from the Perl-Python
    © a-day mailing list at
    © http://groups.yahoo.com/group/perl-python/
    © to subscribe, send an email to
    © if
    © you are reading it on a web page,
    © program examples may not run because
    © groups.google.com changes the post slightly.
    ©
    © Xah
    ©
    © http://xahlee.org/PageTwo_dir/more.html
     
    Xah Lee, Jan 15, 2005
    #1
    1. Advertising

  2. Xah Lee wrote:

    > © a = range(1,51)
    > © for x in a:
    > © if x % 2 == 0:
    > © print x, 'even'


    Now he's mixing tabs and spaces. Hideous.

    Are you doing things wrong on purpose?
    --
    Michael Hoffman
     
    Michael Hoffman, Jan 15, 2005
    #2
    1. Advertising

  3. On Sat, 15 Jan 2005 10:54:28 +0000, Michael Hoffman wrote:

    > Xah Lee wrote:
    >
    >> © a = range(1,51)
    >> © for x in a:
    >> © if x % 2 == 0:
    >> © print x, 'even'

    >
    > Now he's mixing tabs and spaces. Hideous.
    >
    > Are you doing things wrong on purpose?


    I think the most exciting thing is the breath-taking pace he has chosen. I
    mean, wow, we've been going for what, five days now and we're up to for
    loops? Woo!

    So far, even for his stated purpose, he's at negative value vs. just
    reading even the simplest tutorials for the languages. The value in
    Perl<->Python documentation is to help with idiom translation, syntax is
    truly trivial. At the rate he's going, he'll get out of Negative Value and
    start entering Colossal Waste Of Time in about a month.

    So good on you, Xah Lee. The world needs more people producing things of
    negative value and posting them everywhere they can. Wouldn't want The
    Masses (TM) to find the good resources, learn, and subsequently compete
    with people who know things already.

    (Hell, five days into Python and some people are already producing working
    Backgammon games (I think that was the post last week), and Xah Lee here
    is still on for loops! Woo! Go Xah!)
     
    Jeremy Bowers, Jan 15, 2005
    #3
  4. Xah Lee

    Steve Holden Guest

    Michael Hoffman wrote:

    > Xah Lee wrote:
    >
    >> © a = range(1,51)
    >> © for x in a:
    >> © if x % 2 == 0:
    >> © print x, 'even'

    >
    >
    > Now he's mixing tabs and spaces. Hideous.
    >
    > Are you doing things wrong on purpose?


    Actually Xah is to be commended, since he's united the Perl and Python
    camps. Both agree he's a nuisance who is ill-informed about Perl *and*
    Python ;-)

    I can only presume it's egocentricity that keeps him cross-posting this
    nonsense to c.l.py and c.l.pe.misc despite the many deficiencies that
    have been remarked upon in both newsgroups.

    fraternal-greetings-to-the-perl-wordl-ly y'rs - steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
     
    Steve Holden, Jan 15, 2005
    #4
  5. Xah Lee

    BrainDead Guest

    Re: 20050115, for statement

    Steve Holden wrote:
    > Michael Hoffman wrote:
    >
    > > Xah Lee wrote:
    > >
    > >> © a = range(1,51)
    > >> © for x in a:
    > >> © if x % 2 == 0:
    > >> © print x, 'even'

    > >
    > >
    > > Now he's mixing tabs and spaces. Hideous.
    > >
    > > Are you doing things wrong on purpose?

    >
    > Actually Xah is to be commended, since he's united the Perl and

    Python
    > camps. Both agree he's a nuisance who is ill-informed about Perl

    *and*
    > Python ;-)
    >
    > I can only presume it's egocentricity that keeps him cross-posting

    this
    > nonsense to c.l.py and c.l.pe.misc despite the many deficiencies that


    > have been remarked upon in both newsgroups.
    >
    > fraternal-greetings-to-the-perl-wordl-ly y'rs - steve
    > --
    > Steve Holden http://www.holdenweb.com/
    > Python Web Programming http://pydish.holdenweb.com/
    > Holden Web LLC +1 703 861 4237 +1 800 494 3119


    I humbly suggest that Xah Lee Foxtrot Oscar, failing that would he/she
    stand up as the voice is rather muffled. Hardly original I know, but
    this crap is getting up my nose.

    I would much rather read the Timbot discussing things which mention the
    best operating system in the world, i.e. VMS, which for the uninitiated
    stands for Very Much Safer.

    Mark Lawrence.
     
    BrainDead, Jan 15, 2005
    #5
  6. Xah Lee

    Peter Hansen Guest

    Jeremy Bowers wrote:
    > (Hell, five days into Python and some people are already producing working
    > Backgammon games (I think that was the post last week), and Xah Lee here
    > is still on for loops! Woo! Go Xah!)


    Mah Jongg, actually (if we're thinking of the same post), which
    name is often applied in the world of computer games to a what
    amounts to the old game of "Concentration" (rather than the real
    Mah Jongg which bears no more resemblance to the computerized
    version than Bridge bears to Go Fish). The player merely turns
    over cards/tiles two at a time and any identical pairs are removed.
    A backgammon game, with the computer actually playing against a
    human and all the logic that entails, would be much more sophisticated,
    and rather more work.

    ....not to diminish the impressiveness of someone new to Python
    building a visually attractive GUI application in only a few days
    and delivering it to the web which in several ways is far more
    than I've contributed in over five years. ;-) (Doffs hat to the
    former newbie who achieved this.)

    -Peter
     
    Peter Hansen, Jan 17, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    833
  2. Jay McGavren
    Replies:
    11
    Views:
    1,181
    Alan Krueger
    Jan 16, 2006
  3. tedsuzman
    Replies:
    2
    Views:
    7,162
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  4. Ted
    Replies:
    1
    Views:
    493
    Duncan Booth
    Jul 22, 2004
  5. Xah Lee

    [perl-python] 20050115, for statement

    Xah Lee, Jan 15, 2005, in forum: Perl Misc
    Replies:
    0
    Views:
    85
    Xah Lee
    Jan 15, 2005
Loading...

Share This Page