-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
claimed 🐾For new exercises being written by contributors and maintainers.For new exercises being written by contributors and maintainers.maintainer action required❕A maintainer needs to take action on this.A maintainer needs to take action on this.new exercise ✨x:size/largeLarge amount of workLarge amount of workx:status/claimedSomeone is working on this issueSomeone is working on this issue
Description
This issue describes how to implement the other-comprehensions concept exercise for the Python track.
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:
- Contributing to Exercism | Exercism and GitHub | Contributor Pull Request Guide
- What are those Weird Task Tags about?
- Building Language Tracks: An Overview
- What are Concepts?
- Concept Exercise Specifications
- Concept Specifications
- Exercism Formatting and Style Guide
- Exercism Markdown Specification
- Reputation
Goal
The goal of this exercise is to teach the syntax and variants of set comprehensions and dict comprehensions in Python.
Learning objectives
- Understand how
setanddictcomprehensions relate to their underlying data structures and theloop+appendmethod of creating/computing them. - Create a
dictcomprehension from aloop+append - Create a
setcomprehension from aloop+append - Create a
dictcomprehension fromLists,Sets,Tuples, or otheriterables(such aszip()ordict.items()) - Create a
setcomprehension fromLists,Sets,Tuples, or otheriterables(such aszip()ordict.items()) - Use one or more conditions/operators/methods to filter comprehension inputs
- Use methods or logic to format the elements (output members) of the comprehension
- Create a nested comprehension (of either flavor)
- Create a nested comprehension (of either flavor) with one or more formatting or filtering conditions
Out of scope
- Memory and performance characteristics and optimizations
generatorsandgenerator expressionsinother comprehensions- using the data structures in
collectionsin combination with, or as part of asetordictcomprehension. - Using the
assignment expression(walrus operator) with either flavor of comprehension.
Concepts
dict-comprehensionsset-comprehensionscomprehension syntax
Prerequisites
basicsboolsconditionalscomparisonsloopsiteration
Resources to refer to
- List Comprehensions (Python official docs)
- Nested List Comprehensions (Python official docs)
- Comprehending Python's Comprehensions (Dan Bader)
- List and Dict Comprehensions in Python (Timothy Bramlett)
Hints
List Comprehensionssection of the Python docs tutorial: List Comprehensions- This animated GIF from Trey Hunner: List Comprehensions: The Movie
After
comprehension syntaxfor other data structures such assetsanddictionariesgeneratorsandgenerator expressionsgeneratorsandgenerator expressionsinlist comprehensions
Representer
No changes required.
Analyzer
No changes rquired.
Implementing
- Tests should be written using unittest.TestCase, and the test file named list_comprehensions_test.py.
- How to Implement a Concept Exercise in Python
- make-concept-exercise Utility
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.
Metadata
Metadata
Assignees
Labels
claimed 🐾For new exercises being written by contributors and maintainers.For new exercises being written by contributors and maintainers.maintainer action required❕A maintainer needs to take action on this.A maintainer needs to take action on this.new exercise ✨x:size/largeLarge amount of workLarge amount of workx:status/claimedSomeone is working on this issueSomeone is working on this issue