[New Concept Exercise] : itertools
Module
#3088
Labels
new exercise ✨
x:action/create
Work on something from scratch
x:knowledge/intermediate
Quite a bit of Exercism knowledge required
x:module/concept-exercise
Work on Concept Exercises
x:rep/large
Large amount of reputation
x:size/large
Large amount of work
x:status/claimed
Someone is working on this issue
x:type/content
Work on content (e.g. exercises, concepts)
This issue describes how to implement the
itertools
Module concept exercise for the Python track.The related concept documents issue can be found here.
✅ Getting started
If you have not yet created or contributed to a concept exercise, this issue will require some upfront reading to give you the needed background knowledge. Some good example exercises to look at in the repo:
💡Example Exercises💡 (click to expand)
We also recommend completing one or more of the concept exercises (they're called "learning exercises") on the website.
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 go through the following documents:General Contributing Docs:
Documents on Language Tracks and Concept Exercises
🎯 Goal
The goal of the concept exercise described in this issue is to teach understanding/use of the
itertools
module in Python.💡Learning objectives
Learn more about
iteration
tools the Python Standard Library provides through theitertools
module.Build and understanding of and use the following functions from the module, as well as practicing some of the recipes included :
count()
,cycle()
,, orrepeat()
accumulate()
product()
chain()
&chain.from_iterable()
groupby()
islice()
zip_longest()
and thezip() built-in
permutations()
combinations()
🤔 Concepts
iteration
iterators
itertools
🚫 Topics that are Out of scope
Concepts & Subjects that are Out of Scope (click to expand)
classes
&class customization
beyond the use of theitertools
methods.class-inheritance
beyond what is needed to customizeiteration
usingitertools
comprehensions
beyond what is needed to work withitertools
comprehensions
inlambdas
coroutines
decorators
beyond what is needed to work withitertools
functions
andhigher-order functions
beyond what might be needed to work withitertools
functools
and relatedmap()
,filter()
andfunctools.reduce()
(they have their own exercise which is a prerequisite to this one)generators
beyond what might be needed to work withitertools
(they have their own exercise which is a prerequisite to this one)lambdas
beyond what might be needed to work withitertools
assignment expression
or "walrus" operator (:=
)enums
↩️ Prerequisites
These are the concepts/concept exercises the student should be familiar with before taking on/learning this concept.
Exercise Prerequisites (click to expand)
basics
booleans
comparisons
rich-comparisons
dicts
dict-methods
functions
functional tools
generators
higher-order functions
is
andis not
iteration
lists
list-methods
loops
numbers
sequences
sets
strings
string-methods
tuples
📚 Resources for Writing and Reference
Resources (click to expand)
for
Loops Work in Pythonitertools
moduleitertools
Recipesitertools
iterator
in Pythoniterator
PatternExercise Ideas & Stories
Should you need inspiration for an exercise story, you can find a collection here. You can also port an exercise from another track, but please make sure to only to include tasks that actually make sense in Python and that add value for a student. Remove/replace/add tasks as needed to make the concept clear/workable.
📁 Exercise Files to Be Created
File Detail for this Exercise
Exercise
introduction.md
For more information, see Exercise
introduction.md
about
or theintroduction
). The summary does need to have enough information and examples for the student to complete all the tasks outlined for this concept exercise.Exercise
instructions.md
For more information, see
instructions.md
Instructions for an exercise usually center on a story that sets up the code challenge to be solved. You can create your own story, or fork one from the ones listed here. Please make sure to give credit to the original authors if you use a story or fork an exercise.
Exercise
Exemplar.py
SolutionFor more information, see exemplar implementation.
This file should not use syntax or datas structures not introduced in this exercise or in this exercise's prerequisites. It will be used as an "ideal" solution for the challenge, so make sure it conforms to PEP8 and other formatting conventions, and does not use single letter variable names. It should also include proper module and function-level docstrings. However, it should NOT include typehinting or type aliases.
<Exercise>.py
(Stub) for ImplementationFor more information, see stub implementation.
This file should provide the expected function names imported for testing, and optionally TODO comments and or docstrings to aid the student in their implementation. TODOs and docstrings are not required.
<Exercise>_Test.py
FilesFor more information, see Tests.
Additionally, please note that Python associates exercise tasks to tests via a Pytest Marker, and uses
unittest subtests
as a form of test paramaterization. See the test file forLittle Sisters Vocab
for examples of how these techniques work.Exercise
Hints.md
For more information on writing hints see
hints.md
Exercise Metadata Files Under
.meta/config.json
For more information on exercise
.meta/
files and formatting, see concept exercise metadata files.meta/config.json
- see this link for the fields and formatting of this file..meta/design.md
- see this link for the formatting of this file. Please use the Goal, Learning Objectives,Concepts, Prerequisites and , Out of Scope sections from this issue.♾️ Exercise Metadata - Track
For more information on concept exercises and formatting for the Python track
config.json
, please seeconfig.json
. The trackconfig.json
file can be found in the root of the Python repo.You can use the below for the exercise UUID. You can also generate a new one via exercism configlet, uuidgenerator.net, or any other favorite method. The UUID must be a valid V4 UUID.
c4620b29-0db0-4541-8cfe-7048fab27f7f
🎶 Implementation Notes
As a reminder, code in the
.meta/examplar.py
file should only use syntax & concepts introduced in this exercise or one of its prerequisite exercises. We run all ourexamplar.py
files through PyLint, but do not strictly require module docstrings. We do require function docstrings similar to PEP257. See this concept exerciseexemplar.py
for an example.Please do not use comprehensions, generator expressions, or other syntax not previously covered either in the introduction to this exercise, or to one of its prerequisites. Please also follow PEP8 guidelines.
In General, tests should be written using
unittest.TestCase
and the test file should be named<EXERCISE-NAME>_test.py
.PyTest custom mark
to link test cases to exercise task numbers.unittest.subtest
to parameterize test input where/when needed.Here is an example testfile that shows all three of these in action.
While we do use PyTest as our test runner and for some implementation tests, please check with a maintainer before using a PyTest-specific test method, fixture, or feature.
Our markdown and JSON files are checked against prettier . We recommend setting prettier up locally and running it prior to submitting your PR to avoid any CI errors.
🆘 Next Steps & Getting Help
If you'd like to work on this issue, comment saying "I'd like to work on this"
(there is no real need to wait for a response, just go ahead, we'll assign you and put a[claimed]
label on the issue).The text was updated successfully, but these errors were encountered: