Range and For

>>> range(5)
[0, 1, 2, 3, 4]
>>> for i in range(5):
...   print i

7 Responses to Range and For

  1. Pingback: Consolidation: CryptoPyThy « Python Tutorials for Kids 8+

  2. jscubbage says:

    I really feel like a little more explanation is needed here. All the other examples talked about what was going on, but this one didn’t. Why did range(5) not go to 5? I know it’s because it create a zero based array and added 5 items to it, but this might not be so obvious to our young readers. Also, we just did our first loop with nary a mention of how important or power they are.

  3. Alex Harper says:

    This needs more explanation, not just the Python command stuff to follow. 10 year olds like me don’t understand.

  4. brendanscott says:

    Hi Alex (and jscubbuage),
    Part of my motivation is to have students fend for themselves a bit. As the course goes on it has more explanation (possibly too much!).
    [This particular tutorial is an exercise in empiricism. I’m not trying to show what range(5) means so much as what it is.]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: