swcarpentry / DEPRECATED-bc

DEPRECATED: This repository is now frozen - please see individual lesson repositories.
Other
299 stars 383 forks source link

Remove description of strides from novice Python 01 #692

Closed ethanwhite closed 9 years ago

ethanwhite commented 9 years ago

The current section on slicing is already relatively long. Since we don't use strides anywhere else in the novice Python material this removes them to avoid overwhelming the students with too much detail too early.

This is a re-roll of #682 following #652 going in. #682 was already positively reviewed.

jdblischak commented 9 years ago

One place where the idea of a stride is utilized is in one of the challenges in 03-loops. The fact that the third argument to range is the stride is not explained at all, presumably because it is so similar to the slide syntax, i.e. the order of start-end-stride, in the slicing examples from the first lesson.

  1. Python has a built-in function called range that creates a list of numbers: range(3) produces [0, 1, 2], range(2, 5) produces [2, 3, 4], and range(2, 10, 3) produces [2, 5, 8]. Using range, write a function that prints the $N$ natural numbers:

    print_N(3)
    1
    2
    3
ethanwhite commented 9 years ago

Good catch @jdblischak. We actually don't need that material there either and it has the potential to make the exercise more confusing, so I've gone ahead removed that extra material as well.

jdblischak commented 9 years ago

Agreed. And actually I think you should go one step more. This exercise, and also the future uses of range in the following lessons, only provide one argument. The fact that two arguments can be supplied is not necessary to demonstrate, and also potentially confusing since in range(x), the first argument is the end value, and in range(x, y), the first argument is the start value.

$ grep "range(" novice/python/*md
novice/python/03-loop.md:    `range(3)` produces `[0, 1, 2]`, `range(2, 5)` produces `[2, 3, 4]`, and `range(2, 10, 3)` produces `[2, 5, 8]`.
novice/python/04-cond.md:    for x in range(10):
novice/python/04-cond.md:for x in range(square.width):
novice/python/04-cond.md:    for y in range(square.height):
novice/python/04-cond.md:<pre class="in"><code>for x in range(width):
novice/python/04-cond.md:    for y in range(height):
novice/python/04-cond.md:for x in range(width):
novice/python/04-cond.md:    for y in range(height):
novice/python/04-cond.md:    for x in range(width):
novice/python/04-cond.md:        for y in range(height):
novice/python/04-cond.md:    for x in range(width):
novice/python/04-cond.md:        for y in range(height):
novice/python/07-errors.md:<pre class="in"><code>for number in range(10):
novice/python/07-errors.md:      1 for number in range(10):
novice/python/07-errors.md:for number in range(10):
novice/python/07-errors.md:      2 for number in range(10):
novice/python/07-errors.md:<pre class="in"><code>for number in range(10):
novice/python/spatial-intro.md:    basemap_graph.drawmeridians(np.arange(-180,180,20))
novice/python/spatial-intro.md:    basemap_graph.drawparallels(np.arange(-90,90,20))
ethanwhite commented 9 years ago

Actually the exercise in question asks to print the natural numbers, which start at 1, so we'd need to change the exercise to start printing at 0.

jdblischak commented 9 years ago

Ah, true. I am currently working on the R lesson, and the equivalent function, seq, automatically starts at 1. Therefore, I removed the two-argument version from the R lesson.

I am +1 for this PR as it stands, and am indifferent as to whether the Python version of the exercise counts from 1 or 0.

ethanwhite commented 9 years ago

@gvwilson I think this one is probably ready to merge if you don't have any objections.