This issue describes how to implement the sets concept exercise for the Python track.
This will be closed by #2485
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
The goal of this exercise is to teach the basics of the set (set type) in Python.
Learning objectives
- understand that a set is an unordered collection of distinct hashable objects
- create a
set via constructor (set()) and literal ({})
- de-dupe a list of elements by converting a sequence type such as a list to a set type
- check for a membership of an element in a given set via
in
- set comparison functions and set comparison operators (
=<, >=, issubset(), issuperset(), etc.)
- additional set operators (
union, intersection, difference, and symmetric_difference)
- add values to a given set via
add()
- remove values from a given set via
discard()
- iterate through a given set by using
for item in set
Out of scope
frozenset()
clear() to delete all elements of a set
- check the length of a given set via
len()
remove as opposed to discard (remove tosses a keyerror if the element is not present)
- all forms/variants of
update()
- remove (and use) a value from a given set via
pop()
- make shallow copy(s) of a given set via
copy()
- using additional builtins such as
sorted(), min(), or map() with a set
- set comprehensions
Concepts
sets
hashable objects
set comparisons
set operations
Prerequisites
basics
booleans
comparisons
dicts
lists
loops
Resources to refer to
Hints
Hints should link to the Sets section of the Python docs tutorial: Sets
After
After, the student can explore comprehension syntax, although it will be taught in separate exercises. This would also be a good time to explore set comparisons via function &/or operator, or experimenting with the issuperset() & issubset() functions.
Representer
No changes required.
Analyzer
No changes required.
Implementing
Tests should be written using unittest.TestCase, and the test file named dicts_basic_test.py.
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.
Edits
This issue describes how to implement the
setsconcept exercise for the Python track.This will be closed by #2485
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
The goal of this exercise is to teach the basics of the set (set type) in Python.
Learning objectives
setvia constructor (set()) and literal ({})in=<,>=,issubset(),issuperset(), etc.)union,intersection,difference, andsymmetric_difference)add()discard()for item in setOut of scope
frozenset()clear()to delete all elements of a setlen()removeas opposed todiscard(removetosses akeyerrorif the element is not present)update()pop()copy()sorted(),min(), ormap()with a setConcepts
setshashableobjectssetcomparisonssetoperationsPrerequisites
basicsbooleanscomparisonsdictslistsloopsResources to refer to
Hints
Hints should link to the
Setssection of the Python docs tutorial: SetsAfter
After, the student can explore comprehension syntax, although it will be taught in separate exercises. This would also be a good time to explore set comparisons via function &/or operator, or experimenting with the
issuperset()&issubset()functions.Representer
No changes required.
Analyzer
No changes required.
Implementing
Tests should be written using unittest.TestCase, and the test file named dicts_basic_test.py.
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.
Edits