exercism / v3

The work-in-progress project for developing v3 tracks
https://v3.exercism.io
Other
170 stars 163 forks source link

[Python] Implement new Concept Exercise: range #2176

Closed DavidGerva closed 3 years ago

DavidGerva commented 4 years ago

This issue describes how to implement the range type concept exercise for the Python track: should explain what range is and how to use it in python.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

Goal of the exercises is to teach the student the use of the range type, an immutable sequence of numbers in python. range is commonly used for looping a specific number of times in for loops.

Learning objectives

Out of scope

Concepts

Prerequisites

Resources to refer to

Hints

After

Go deeper inside the range call: exception handling for step passed 0 (If a step is zero Python raises a ValueError exception), explain how to use it with negative arguments. Spend some words on the advantage of the range type over a regular list or tuple: a range object will always take the same (small) amount of memory, no matter the size of the range it represents (as it only stores the start, stop and step values, calculating individual items and subranges as needed).

Representer

No changes required.

Analyzer

No changes required.

Implementing

Tests should be written using unittest.TestCase and the test file named comparisons_test.py.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

Edits

-

BethanyG commented 3 years ago

@DavidGerva @cmccandless -- I really really hate doing this. But when I look at this concept exercise, it feels as though it belongs either with iterables, iteration or loops as a concept -- and not on its own as a stand-alone. Thoughts?

cmccandless commented 3 years ago

I don't really think range is a separate concept. It's not a keyword or a type, it's just a builtin function (albeit a common one).

BethanyG commented 3 years ago

Yeah. It is a "shortcut" sequence type for counting or iterating. So that us lazy pythonistas don't have to always declare a loop counter. ;-). And the python docs sorta treat it as such. Ok. Booting. This concept thing is .... frustrating. Apologies to the both of you for the churn and chaos.

cmccandless commented 3 years ago

This concept thing is .... frustrating. Apologies to the both of you for the churn and chaos.

Not at all! The only stupid questions are the ones left un-asked :smile: