pythonlings 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythonlings/__init__.py +0 -0
- pythonlings/__main__.py +4 -0
- pythonlings/app.py +84 -0
- pythonlings/cli.py +318 -0
- pythonlings/core/__init__.py +0 -0
- pythonlings/core/curriculum.py +106 -0
- pythonlings/core/docs.py +68 -0
- pythonlings/core/exercise.py +33 -0
- pythonlings/core/manifest.py +110 -0
- pythonlings/core/reset.py +43 -0
- pythonlings/core/runner.py +114 -0
- pythonlings/core/solutions.py +17 -0
- pythonlings/core/state.py +86 -0
- pythonlings/curriculum/checks/async/async1.py +4 -0
- pythonlings/curriculum/checks/async/async10.py +4 -0
- pythonlings/curriculum/checks/async/async2.py +4 -0
- pythonlings/curriculum/checks/async/async3.py +4 -0
- pythonlings/curriculum/checks/async/async4.py +4 -0
- pythonlings/curriculum/checks/async/async5.py +4 -0
- pythonlings/curriculum/checks/async/async6.py +4 -0
- pythonlings/curriculum/checks/async/async7.py +4 -0
- pythonlings/curriculum/checks/async/async8.py +2 -0
- pythonlings/curriculum/checks/async/async9.py +4 -0
- pythonlings/curriculum/checks/classes/classes1.py +3 -0
- pythonlings/curriculum/checks/classes/classes10.py +5 -0
- pythonlings/curriculum/checks/classes/classes11.py +5 -0
- pythonlings/curriculum/checks/classes/classes12.py +16 -0
- pythonlings/curriculum/checks/classes/classes2.py +3 -0
- pythonlings/curriculum/checks/classes/classes3.py +4 -0
- pythonlings/curriculum/checks/classes/classes4.py +4 -0
- pythonlings/curriculum/checks/classes/classes5.py +5 -0
- pythonlings/curriculum/checks/classes/classes6.py +4 -0
- pythonlings/curriculum/checks/classes/classes7.py +3 -0
- pythonlings/curriculum/checks/classes/classes8.py +3 -0
- pythonlings/curriculum/checks/classes/classes9.py +4 -0
- pythonlings/curriculum/checks/collections/collections1.py +4 -0
- pythonlings/curriculum/checks/collections/collections10.py +15 -0
- pythonlings/curriculum/checks/collections/collections2.py +4 -0
- pythonlings/curriculum/checks/collections/collections3.py +5 -0
- pythonlings/curriculum/checks/collections/collections4.py +4 -0
- pythonlings/curriculum/checks/collections/collections5.py +5 -0
- pythonlings/curriculum/checks/collections/collections6.py +6 -0
- pythonlings/curriculum/checks/collections/collections7.py +4 -0
- pythonlings/curriculum/checks/collections/collections8.py +5 -0
- pythonlings/curriculum/checks/collections/collections9.py +9 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions1.py +3 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions10.py +5 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions2.py +3 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions3.py +3 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions4.py +6 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions5.py +3 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions6.py +3 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions7.py +4 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions8.py +5 -0
- pythonlings/curriculum/checks/comprehensions/comprehensions9.py +3 -0
- pythonlings/curriculum/checks/conditionals/conditionals1.py +2 -0
- pythonlings/curriculum/checks/conditionals/conditionals10.py +10 -0
- pythonlings/curriculum/checks/conditionals/conditionals2.py +5 -0
- pythonlings/curriculum/checks/conditionals/conditionals3.py +9 -0
- pythonlings/curriculum/checks/conditionals/conditionals4.py +7 -0
- pythonlings/curriculum/checks/conditionals/conditionals5.py +9 -0
- pythonlings/curriculum/checks/conditionals/conditionals6.py +7 -0
- pythonlings/curriculum/checks/conditionals/conditionals7.py +7 -0
- pythonlings/curriculum/checks/conditionals/conditionals8.py +9 -0
- pythonlings/curriculum/checks/conditionals/conditionals9.py +7 -0
- pythonlings/curriculum/checks/context_managers/context_managers1.py +15 -0
- pythonlings/curriculum/checks/context_managers/context_managers2.py +10 -0
- pythonlings/curriculum/checks/context_managers/context_managers3.py +2 -0
- pythonlings/curriculum/checks/context_managers/context_managers4.py +3 -0
- pythonlings/curriculum/checks/context_managers/context_managers5.py +5 -0
- pythonlings/curriculum/checks/context_managers/context_managers6.py +4 -0
- pythonlings/curriculum/checks/context_managers/context_managers7.py +16 -0
- pythonlings/curriculum/checks/context_managers/context_managers8.py +15 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses1.py +3 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses2.py +5 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses3.py +4 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses4.py +3 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses5.py +9 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses6.py +6 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses7.py +6 -0
- pythonlings/curriculum/checks/dataclasses/dataclasses8.py +5 -0
- pythonlings/curriculum/checks/datetime/datetime1.py +4 -0
- pythonlings/curriculum/checks/datetime/datetime2.py +4 -0
- pythonlings/curriculum/checks/datetime/datetime3.py +6 -0
- pythonlings/curriculum/checks/datetime/datetime4.py +2 -0
- pythonlings/curriculum/checks/datetime/datetime5.py +2 -0
- pythonlings/curriculum/checks/datetime/datetime6.py +2 -0
- pythonlings/curriculum/checks/datetime/datetime7.py +2 -0
- pythonlings/curriculum/checks/datetime/datetime8.py +5 -0
- pythonlings/curriculum/checks/decorators/decorators1.py +8 -0
- pythonlings/curriculum/checks/decorators/decorators10.py +12 -0
- pythonlings/curriculum/checks/decorators/decorators2.py +5 -0
- pythonlings/curriculum/checks/decorators/decorators3.py +4 -0
- pythonlings/curriculum/checks/decorators/decorators4.py +7 -0
- pythonlings/curriculum/checks/decorators/decorators5.py +5 -0
- pythonlings/curriculum/checks/decorators/decorators6.py +8 -0
- pythonlings/curriculum/checks/decorators/decorators7.py +12 -0
- pythonlings/curriculum/checks/decorators/decorators8.py +20 -0
- pythonlings/curriculum/checks/decorators/decorators9.py +4 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries1.py +3 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries10.py +5 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries2.py +2 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries3.py +5 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries4.py +5 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries5.py +11 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries6.py +4 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries7.py +5 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries8.py +4 -0
- pythonlings/curriculum/checks/dictionaries/dictionaries9.py +4 -0
- pythonlings/curriculum/checks/enums/enums1.py +4 -0
- pythonlings/curriculum/checks/enums/enums2.py +3 -0
- pythonlings/curriculum/checks/enums/enums3.py +3 -0
- pythonlings/curriculum/checks/enums/enums4.py +2 -0
- pythonlings/curriculum/checks/enums/enums5.py +4 -0
- pythonlings/curriculum/checks/enums/enums6.py +3 -0
- pythonlings/curriculum/checks/exceptions/exceptions1.py +4 -0
- pythonlings/curriculum/checks/exceptions/exceptions10.py +39 -0
- pythonlings/curriculum/checks/exceptions/exceptions2.py +5 -0
- pythonlings/curriculum/checks/exceptions/exceptions3.py +8 -0
- pythonlings/curriculum/checks/exceptions/exceptions4.py +5 -0
- pythonlings/curriculum/checks/exceptions/exceptions5.py +10 -0
- pythonlings/curriculum/checks/exceptions/exceptions6.py +17 -0
- pythonlings/curriculum/checks/exceptions/exceptions7.py +15 -0
- pythonlings/curriculum/checks/exceptions/exceptions8.py +6 -0
- pythonlings/curriculum/checks/exceptions/exceptions9.py +16 -0
- pythonlings/curriculum/checks/file_io/file_io1.py +15 -0
- pythonlings/curriculum/checks/file_io/file_io10.py +16 -0
- pythonlings/curriculum/checks/file_io/file_io2.py +10 -0
- pythonlings/curriculum/checks/file_io/file_io3.py +15 -0
- pythonlings/curriculum/checks/file_io/file_io4.py +14 -0
- pythonlings/curriculum/checks/file_io/file_io5.py +15 -0
- pythonlings/curriculum/checks/file_io/file_io6.py +10 -0
- pythonlings/curriculum/checks/file_io/file_io7.py +15 -0
- pythonlings/curriculum/checks/file_io/file_io8.py +12 -0
- pythonlings/curriculum/checks/file_io/file_io9.py +10 -0
- pythonlings/curriculum/checks/functional/functional1.py +4 -0
- pythonlings/curriculum/checks/functional/functional10.py +7 -0
- pythonlings/curriculum/checks/functional/functional2.py +5 -0
- pythonlings/curriculum/checks/functional/functional3.py +3 -0
- pythonlings/curriculum/checks/functional/functional4.py +4 -0
- pythonlings/curriculum/checks/functional/functional5.py +6 -0
- pythonlings/curriculum/checks/functional/functional6.py +8 -0
- pythonlings/curriculum/checks/functional/functional7.py +8 -0
- pythonlings/curriculum/checks/functional/functional8.py +7 -0
- pythonlings/curriculum/checks/functional/functional9.py +8 -0
- pythonlings/curriculum/checks/functions/functions1.py +9 -0
- pythonlings/curriculum/checks/functions/functions10.py +12 -0
- pythonlings/curriculum/checks/functions/functions2.py +4 -0
- pythonlings/curriculum/checks/functions/functions3.py +6 -0
- pythonlings/curriculum/checks/functions/functions4.py +6 -0
- pythonlings/curriculum/checks/functions/functions5.py +6 -0
- pythonlings/curriculum/checks/functions/functions6.py +8 -0
- pythonlings/curriculum/checks/functions/functions7.py +7 -0
- pythonlings/curriculum/checks/functions/functions8.py +6 -0
- pythonlings/curriculum/checks/functions/functions9.py +7 -0
- pythonlings/curriculum/checks/generators/generators1.py +4 -0
- pythonlings/curriculum/checks/generators/generators10.py +7 -0
- pythonlings/curriculum/checks/generators/generators2.py +3 -0
- pythonlings/curriculum/checks/generators/generators3.py +4 -0
- pythonlings/curriculum/checks/generators/generators4.py +9 -0
- pythonlings/curriculum/checks/generators/generators5.py +10 -0
- pythonlings/curriculum/checks/generators/generators6.py +8 -0
- pythonlings/curriculum/checks/generators/generators7.py +11 -0
- pythonlings/curriculum/checks/generators/generators8.py +8 -0
- pythonlings/curriculum/checks/generators/generators9.py +13 -0
- pythonlings/curriculum/checks/itertools/itertools1.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools2.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools3.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools4.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools5.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools6.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools7.py +2 -0
- pythonlings/curriculum/checks/itertools/itertools8.py +3 -0
- pythonlings/curriculum/checks/json/json1.py +3 -0
- pythonlings/curriculum/checks/json/json2.py +2 -0
- pythonlings/curriculum/checks/json/json3.py +2 -0
- pythonlings/curriculum/checks/json/json4.py +2 -0
- pythonlings/curriculum/checks/json/json5.py +2 -0
- pythonlings/curriculum/checks/json/json6.py +2 -0
- pythonlings/curriculum/checks/json/json7.py +3 -0
- pythonlings/curriculum/checks/json/json8.py +4 -0
- pythonlings/curriculum/checks/lists/lists1.py +2 -0
- pythonlings/curriculum/checks/lists/lists10.py +5 -0
- pythonlings/curriculum/checks/lists/lists2.py +3 -0
- pythonlings/curriculum/checks/lists/lists3.py +4 -0
- pythonlings/curriculum/checks/lists/lists4.py +3 -0
- pythonlings/curriculum/checks/lists/lists5.py +4 -0
- pythonlings/curriculum/checks/lists/lists6.py +3 -0
- pythonlings/curriculum/checks/lists/lists7.py +4 -0
- pythonlings/curriculum/checks/lists/lists8.py +7 -0
- pythonlings/curriculum/checks/lists/lists9.py +4 -0
- pythonlings/curriculum/checks/loops/loops1.py +2 -0
- pythonlings/curriculum/checks/loops/loops10.py +6 -0
- pythonlings/curriculum/checks/loops/loops2.py +2 -0
- pythonlings/curriculum/checks/loops/loops3.py +2 -0
- pythonlings/curriculum/checks/loops/loops4.py +3 -0
- pythonlings/curriculum/checks/loops/loops5.py +2 -0
- pythonlings/curriculum/checks/loops/loops6.py +2 -0
- pythonlings/curriculum/checks/loops/loops7.py +2 -0
- pythonlings/curriculum/checks/loops/loops8.py +2 -0
- pythonlings/curriculum/checks/loops/loops9.py +3 -0
- pythonlings/curriculum/checks/modules/modules1.py +2 -0
- pythonlings/curriculum/checks/modules/modules2.py +2 -0
- pythonlings/curriculum/checks/modules/modules3.py +5 -0
- pythonlings/curriculum/checks/modules/modules4.py +8 -0
- pythonlings/curriculum/checks/modules/modules5.py +7 -0
- pythonlings/curriculum/checks/modules/modules6.py +4 -0
- pythonlings/curriculum/checks/modules/modules7.py +4 -0
- pythonlings/curriculum/checks/modules/modules8.py +15 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced1.py +4 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced10.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced11.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced12.py +4 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced2.py +4 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced3.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced4.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced5.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced6.py +2 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced7.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced8.py +3 -0
- pythonlings/curriculum/checks/oop_advanced/oop_advanced9.py +4 -0
- pythonlings/curriculum/checks/pathlib/pathlib1.py +5 -0
- pythonlings/curriculum/checks/pathlib/pathlib2.py +4 -0
- pythonlings/curriculum/checks/pathlib/pathlib3.py +6 -0
- pythonlings/curriculum/checks/pathlib/pathlib4.py +4 -0
- pythonlings/curriculum/checks/pathlib/pathlib5.py +4 -0
- pythonlings/curriculum/checks/pathlib/pathlib6.py +5 -0
- pythonlings/curriculum/checks/recursion/recursion1.py +5 -0
- pythonlings/curriculum/checks/recursion/recursion2.py +5 -0
- pythonlings/curriculum/checks/recursion/recursion3.py +6 -0
- pythonlings/curriculum/checks/recursion/recursion4.py +6 -0
- pythonlings/curriculum/checks/recursion/recursion5.py +7 -0
- pythonlings/curriculum/checks/recursion/recursion6.py +7 -0
- pythonlings/curriculum/checks/recursion/recursion7.py +7 -0
- pythonlings/curriculum/checks/recursion/recursion8.py +15 -0
- pythonlings/curriculum/checks/regex/regex1.py +3 -0
- pythonlings/curriculum/checks/regex/regex10.py +17 -0
- pythonlings/curriculum/checks/regex/regex2.py +3 -0
- pythonlings/curriculum/checks/regex/regex3.py +2 -0
- pythonlings/curriculum/checks/regex/regex4.py +4 -0
- pythonlings/curriculum/checks/regex/regex5.py +4 -0
- pythonlings/curriculum/checks/regex/regex6.py +6 -0
- pythonlings/curriculum/checks/regex/regex7.py +5 -0
- pythonlings/curriculum/checks/regex/regex8.py +6 -0
- pythonlings/curriculum/checks/regex/regex9.py +8 -0
- pythonlings/curriculum/checks/sets/sets1.py +3 -0
- pythonlings/curriculum/checks/sets/sets10.py +15 -0
- pythonlings/curriculum/checks/sets/sets2.py +5 -0
- pythonlings/curriculum/checks/sets/sets3.py +5 -0
- pythonlings/curriculum/checks/sets/sets4.py +3 -0
- pythonlings/curriculum/checks/sets/sets5.py +3 -0
- pythonlings/curriculum/checks/sets/sets6.py +3 -0
- pythonlings/curriculum/checks/sets/sets7.py +5 -0
- pythonlings/curriculum/checks/sets/sets8.py +5 -0
- pythonlings/curriculum/checks/sets/sets9.py +3 -0
- pythonlings/curriculum/checks/strings/strings1.py +3 -0
- pythonlings/curriculum/checks/strings/strings10.py +5 -0
- pythonlings/curriculum/checks/strings/strings2.py +3 -0
- pythonlings/curriculum/checks/strings/strings3.py +3 -0
- pythonlings/curriculum/checks/strings/strings4.py +2 -0
- pythonlings/curriculum/checks/strings/strings5.py +4 -0
- pythonlings/curriculum/checks/strings/strings6.py +3 -0
- pythonlings/curriculum/checks/strings/strings7.py +3 -0
- pythonlings/curriculum/checks/strings/strings8.py +3 -0
- pythonlings/curriculum/checks/strings/strings9.py +3 -0
- pythonlings/curriculum/checks/testing/testing1.py +2 -0
- pythonlings/curriculum/checks/testing/testing10.py +9 -0
- pythonlings/curriculum/checks/testing/testing11.py +7 -0
- pythonlings/curriculum/checks/testing/testing12.py +19 -0
- pythonlings/curriculum/checks/testing/testing2.py +2 -0
- pythonlings/curriculum/checks/testing/testing3.py +12 -0
- pythonlings/curriculum/checks/testing/testing4.py +6 -0
- pythonlings/curriculum/checks/testing/testing5.py +6 -0
- pythonlings/curriculum/checks/testing/testing6.py +14 -0
- pythonlings/curriculum/checks/testing/testing7.py +14 -0
- pythonlings/curriculum/checks/testing/testing8.py +27 -0
- pythonlings/curriculum/checks/testing/testing9.py +14 -0
- pythonlings/curriculum/checks/tuples/tuples1.py +3 -0
- pythonlings/curriculum/checks/tuples/tuples10.py +6 -0
- pythonlings/curriculum/checks/tuples/tuples2.py +3 -0
- pythonlings/curriculum/checks/tuples/tuples3.py +4 -0
- pythonlings/curriculum/checks/tuples/tuples4.py +3 -0
- pythonlings/curriculum/checks/tuples/tuples5.py +4 -0
- pythonlings/curriculum/checks/tuples/tuples6.py +5 -0
- pythonlings/curriculum/checks/tuples/tuples7.py +3 -0
- pythonlings/curriculum/checks/tuples/tuples8.py +4 -0
- pythonlings/curriculum/checks/tuples/tuples9.py +5 -0
- pythonlings/curriculum/checks/type_hints/type_hints1.py +3 -0
- pythonlings/curriculum/checks/type_hints/type_hints2.py +5 -0
- pythonlings/curriculum/checks/type_hints/type_hints3.py +5 -0
- pythonlings/curriculum/checks/type_hints/type_hints4.py +5 -0
- pythonlings/curriculum/checks/type_hints/type_hints5.py +6 -0
- pythonlings/curriculum/checks/type_hints/type_hints6.py +7 -0
- pythonlings/curriculum/checks/type_hints/type_hints7.py +9 -0
- pythonlings/curriculum/checks/type_hints/type_hints8.py +9 -0
- pythonlings/curriculum/checks/variables/variables1.py +7 -0
- pythonlings/curriculum/checks/variables/variables10.py +4 -0
- pythonlings/curriculum/checks/variables/variables2.py +19 -0
- pythonlings/curriculum/checks/variables/variables3.py +4 -0
- pythonlings/curriculum/checks/variables/variables4.py +2 -0
- pythonlings/curriculum/checks/variables/variables5.py +2 -0
- pythonlings/curriculum/checks/variables/variables6.py +4 -0
- pythonlings/curriculum/checks/variables/variables7.py +3 -0
- pythonlings/curriculum/checks/variables/variables8.py +4 -0
- pythonlings/curriculum/checks/variables/variables9.py +3 -0
- pythonlings/curriculum/exercises/async/async1.py +7 -0
- pythonlings/curriculum/exercises/async/async10.py +14 -0
- pythonlings/curriculum/exercises/async/async2.py +10 -0
- pythonlings/curriculum/exercises/async/async3.py +10 -0
- pythonlings/curriculum/exercises/async/async4.py +15 -0
- pythonlings/curriculum/exercises/async/async5.py +13 -0
- pythonlings/curriculum/exercises/async/async6.py +14 -0
- pythonlings/curriculum/exercises/async/async7.py +13 -0
- pythonlings/curriculum/exercises/async/async8.py +11 -0
- pythonlings/curriculum/exercises/async/async9.py +13 -0
- pythonlings/curriculum/exercises/classes/classes1.py +13 -0
- pythonlings/curriculum/exercises/classes/classes10.py +22 -0
- pythonlings/curriculum/exercises/classes/classes11.py +24 -0
- pythonlings/curriculum/exercises/classes/classes12.py +33 -0
- pythonlings/curriculum/exercises/classes/classes2.py +13 -0
- pythonlings/curriculum/exercises/classes/classes3.py +13 -0
- pythonlings/curriculum/exercises/classes/classes4.py +16 -0
- pythonlings/curriculum/exercises/classes/classes5.py +18 -0
- pythonlings/curriculum/exercises/classes/classes6.py +15 -0
- pythonlings/curriculum/exercises/classes/classes7.py +18 -0
- pythonlings/curriculum/exercises/classes/classes8.py +14 -0
- pythonlings/curriculum/exercises/classes/classes9.py +18 -0
- pythonlings/curriculum/exercises/collections/collections1.py +11 -0
- pythonlings/curriculum/exercises/collections/collections10.py +37 -0
- pythonlings/curriculum/exercises/collections/collections2.py +18 -0
- pythonlings/curriculum/exercises/collections/collections3.py +17 -0
- pythonlings/curriculum/exercises/collections/collections4.py +26 -0
- pythonlings/curriculum/exercises/collections/collections5.py +14 -0
- pythonlings/curriculum/exercises/collections/collections6.py +18 -0
- pythonlings/curriculum/exercises/collections/collections7.py +20 -0
- pythonlings/curriculum/exercises/collections/collections8.py +23 -0
- pythonlings/curriculum/exercises/collections/collections9.py +21 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions1.py +10 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions10.py +15 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions2.py +12 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions3.py +12 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions4.py +14 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions5.py +12 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions6.py +12 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions7.py +12 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions8.py +15 -0
- pythonlings/curriculum/exercises/comprehensions/comprehensions9.py +13 -0
- pythonlings/curriculum/exercises/conditionals/conditionals1.py +15 -0
- pythonlings/curriculum/exercises/conditionals/conditionals10.py +18 -0
- pythonlings/curriculum/exercises/conditionals/conditionals2.py +13 -0
- pythonlings/curriculum/exercises/conditionals/conditionals3.py +18 -0
- pythonlings/curriculum/exercises/conditionals/conditionals4.py +20 -0
- pythonlings/curriculum/exercises/conditionals/conditionals5.py +17 -0
- pythonlings/curriculum/exercises/conditionals/conditionals6.py +15 -0
- pythonlings/curriculum/exercises/conditionals/conditionals7.py +18 -0
- pythonlings/curriculum/exercises/conditionals/conditionals8.py +20 -0
- pythonlings/curriculum/exercises/conditionals/conditionals9.py +12 -0
- pythonlings/curriculum/exercises/context_managers/context_managers1.py +18 -0
- pythonlings/curriculum/exercises/context_managers/context_managers2.py +19 -0
- pythonlings/curriculum/exercises/context_managers/context_managers3.py +24 -0
- pythonlings/curriculum/exercises/context_managers/context_managers4.py +30 -0
- pythonlings/curriculum/exercises/context_managers/context_managers5.py +30 -0
- pythonlings/curriculum/exercises/context_managers/context_managers6.py +26 -0
- pythonlings/curriculum/exercises/context_managers/context_managers7.py +30 -0
- pythonlings/curriculum/exercises/context_managers/context_managers8.py +45 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses1.py +14 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses2.py +23 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses3.py +21 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses4.py +25 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses5.py +25 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses6.py +21 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses7.py +27 -0
- pythonlings/curriculum/exercises/dataclasses/dataclasses8.py +30 -0
- pythonlings/curriculum/exercises/datetime/datetime1.py +8 -0
- pythonlings/curriculum/exercises/datetime/datetime2.py +9 -0
- pythonlings/curriculum/exercises/datetime/datetime3.py +9 -0
- pythonlings/curriculum/exercises/datetime/datetime4.py +9 -0
- pythonlings/curriculum/exercises/datetime/datetime5.py +10 -0
- pythonlings/curriculum/exercises/datetime/datetime6.py +10 -0
- pythonlings/curriculum/exercises/datetime/datetime7.py +10 -0
- pythonlings/curriculum/exercises/datetime/datetime8.py +11 -0
- pythonlings/curriculum/exercises/decorators/decorators1.py +19 -0
- pythonlings/curriculum/exercises/decorators/decorators10.py +32 -0
- pythonlings/curriculum/exercises/decorators/decorators2.py +22 -0
- pythonlings/curriculum/exercises/decorators/decorators3.py +18 -0
- pythonlings/curriculum/exercises/decorators/decorators4.py +24 -0
- pythonlings/curriculum/exercises/decorators/decorators5.py +25 -0
- pythonlings/curriculum/exercises/decorators/decorators6.py +19 -0
- pythonlings/curriculum/exercises/decorators/decorators7.py +25 -0
- pythonlings/curriculum/exercises/decorators/decorators8.py +25 -0
- pythonlings/curriculum/exercises/decorators/decorators9.py +26 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries1.py +6 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries10.py +17 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries2.py +9 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries3.py +16 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries4.py +15 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries5.py +15 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries6.py +18 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries7.py +17 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries8.py +17 -0
- pythonlings/curriculum/exercises/dictionaries/dictionaries9.py +25 -0
- pythonlings/curriculum/exercises/enums/enums1.py +12 -0
- pythonlings/curriculum/exercises/enums/enums2.py +11 -0
- pythonlings/curriculum/exercises/enums/enums3.py +14 -0
- pythonlings/curriculum/exercises/enums/enums4.py +13 -0
- pythonlings/curriculum/exercises/enums/enums5.py +14 -0
- pythonlings/curriculum/exercises/enums/enums6.py +15 -0
- pythonlings/curriculum/exercises/exceptions/exceptions1.py +15 -0
- pythonlings/curriculum/exercises/exceptions/exceptions10.py +19 -0
- pythonlings/curriculum/exercises/exceptions/exceptions2.py +12 -0
- pythonlings/curriculum/exercises/exceptions/exceptions3.py +13 -0
- pythonlings/curriculum/exercises/exceptions/exceptions4.py +17 -0
- pythonlings/curriculum/exercises/exceptions/exceptions5.py +20 -0
- pythonlings/curriculum/exercises/exceptions/exceptions6.py +13 -0
- pythonlings/curriculum/exercises/exceptions/exceptions7.py +15 -0
- pythonlings/curriculum/exercises/exceptions/exceptions8.py +17 -0
- pythonlings/curriculum/exercises/exceptions/exceptions9.py +20 -0
- pythonlings/curriculum/exercises/file_io/file_io1.py +18 -0
- pythonlings/curriculum/exercises/file_io/file_io10.py +25 -0
- pythonlings/curriculum/exercises/file_io/file_io2.py +16 -0
- pythonlings/curriculum/exercises/file_io/file_io3.py +18 -0
- pythonlings/curriculum/exercises/file_io/file_io4.py +21 -0
- pythonlings/curriculum/exercises/file_io/file_io5.py +19 -0
- pythonlings/curriculum/exercises/file_io/file_io6.py +22 -0
- pythonlings/curriculum/exercises/file_io/file_io7.py +20 -0
- pythonlings/curriculum/exercises/file_io/file_io8.py +18 -0
- pythonlings/curriculum/exercises/file_io/file_io9.py +19 -0
- pythonlings/curriculum/exercises/functional/functional1.py +7 -0
- pythonlings/curriculum/exercises/functional/functional10.py +19 -0
- pythonlings/curriculum/exercises/functional/functional2.py +8 -0
- pythonlings/curriculum/exercises/functional/functional3.py +11 -0
- pythonlings/curriculum/exercises/functional/functional4.py +11 -0
- pythonlings/curriculum/exercises/functional/functional5.py +11 -0
- pythonlings/curriculum/exercises/functional/functional6.py +14 -0
- pythonlings/curriculum/exercises/functional/functional7.py +12 -0
- pythonlings/curriculum/exercises/functional/functional8.py +13 -0
- pythonlings/curriculum/exercises/functional/functional9.py +15 -0
- pythonlings/curriculum/exercises/functions/functions1.py +8 -0
- pythonlings/curriculum/exercises/functions/functions10.py +19 -0
- pythonlings/curriculum/exercises/functions/functions2.py +9 -0
- pythonlings/curriculum/exercises/functions/functions3.py +8 -0
- pythonlings/curriculum/exercises/functions/functions4.py +8 -0
- pythonlings/curriculum/exercises/functions/functions5.py +11 -0
- pythonlings/curriculum/exercises/functions/functions6.py +16 -0
- pythonlings/curriculum/exercises/functions/functions7.py +11 -0
- pythonlings/curriculum/exercises/functions/functions8.py +10 -0
- pythonlings/curriculum/exercises/functions/functions9.py +16 -0
- pythonlings/curriculum/exercises/generators/generators1.py +13 -0
- pythonlings/curriculum/exercises/generators/generators10.py +16 -0
- pythonlings/curriculum/exercises/generators/generators2.py +17 -0
- pythonlings/curriculum/exercises/generators/generators3.py +19 -0
- pythonlings/curriculum/exercises/generators/generators4.py +12 -0
- pythonlings/curriculum/exercises/generators/generators5.py +24 -0
- pythonlings/curriculum/exercises/generators/generators6.py +20 -0
- pythonlings/curriculum/exercises/generators/generators7.py +14 -0
- pythonlings/curriculum/exercises/generators/generators8.py +17 -0
- pythonlings/curriculum/exercises/generators/generators9.py +26 -0
- pythonlings/curriculum/exercises/itertools/itertools1.py +10 -0
- pythonlings/curriculum/exercises/itertools/itertools2.py +8 -0
- pythonlings/curriculum/exercises/itertools/itertools3.py +10 -0
- pythonlings/curriculum/exercises/itertools/itertools4.py +12 -0
- pythonlings/curriculum/exercises/itertools/itertools5.py +9 -0
- pythonlings/curriculum/exercises/itertools/itertools6.py +9 -0
- pythonlings/curriculum/exercises/itertools/itertools7.py +10 -0
- pythonlings/curriculum/exercises/itertools/itertools8.py +18 -0
- pythonlings/curriculum/exercises/json/json1.py +10 -0
- pythonlings/curriculum/exercises/json/json2.py +9 -0
- pythonlings/curriculum/exercises/json/json3.py +10 -0
- pythonlings/curriculum/exercises/json/json4.py +13 -0
- pythonlings/curriculum/exercises/json/json5.py +9 -0
- pythonlings/curriculum/exercises/json/json6.py +10 -0
- pythonlings/curriculum/exercises/json/json7.py +10 -0
- pythonlings/curriculum/exercises/json/json8.py +12 -0
- pythonlings/curriculum/exercises/lists/lists1.py +7 -0
- pythonlings/curriculum/exercises/lists/lists10.py +28 -0
- pythonlings/curriculum/exercises/lists/lists2.py +13 -0
- pythonlings/curriculum/exercises/lists/lists3.py +16 -0
- pythonlings/curriculum/exercises/lists/lists4.py +16 -0
- pythonlings/curriculum/exercises/lists/lists5.py +16 -0
- pythonlings/curriculum/exercises/lists/lists6.py +15 -0
- pythonlings/curriculum/exercises/lists/lists7.py +13 -0
- pythonlings/curriculum/exercises/lists/lists8.py +15 -0
- pythonlings/curriculum/exercises/lists/lists9.py +19 -0
- pythonlings/curriculum/exercises/loops/loops1.py +8 -0
- pythonlings/curriculum/exercises/loops/loops10.py +22 -0
- pythonlings/curriculum/exercises/loops/loops2.py +10 -0
- pythonlings/curriculum/exercises/loops/loops3.py +10 -0
- pythonlings/curriculum/exercises/loops/loops4.py +12 -0
- pythonlings/curriculum/exercises/loops/loops5.py +13 -0
- pythonlings/curriculum/exercises/loops/loops6.py +10 -0
- pythonlings/curriculum/exercises/loops/loops7.py +13 -0
- pythonlings/curriculum/exercises/loops/loops8.py +11 -0
- pythonlings/curriculum/exercises/loops/loops9.py +11 -0
- pythonlings/curriculum/exercises/modules/modules1.py +10 -0
- pythonlings/curriculum/exercises/modules/modules2.py +10 -0
- pythonlings/curriculum/exercises/modules/modules3.py +13 -0
- pythonlings/curriculum/exercises/modules/modules4.py +18 -0
- pythonlings/curriculum/exercises/modules/modules5.py +17 -0
- pythonlings/curriculum/exercises/modules/modules6.py +12 -0
- pythonlings/curriculum/exercises/modules/modules7.py +16 -0
- pythonlings/curriculum/exercises/modules/modules8.py +23 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced1.py +11 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced10.py +18 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced11.py +13 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced12.py +12 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced2.py +13 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced3.py +22 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced4.py +12 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced5.py +11 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced6.py +12 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced7.py +14 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced8.py +14 -0
- pythonlings/curriculum/exercises/oop_advanced/oop_advanced9.py +9 -0
- pythonlings/curriculum/exercises/pathlib/pathlib1.py +9 -0
- pythonlings/curriculum/exercises/pathlib/pathlib2.py +9 -0
- pythonlings/curriculum/exercises/pathlib/pathlib3.py +11 -0
- pythonlings/curriculum/exercises/pathlib/pathlib4.py +9 -0
- pythonlings/curriculum/exercises/pathlib/pathlib5.py +9 -0
- pythonlings/curriculum/exercises/pathlib/pathlib6.py +10 -0
- pythonlings/curriculum/exercises/recursion/recursion1.py +12 -0
- pythonlings/curriculum/exercises/recursion/recursion2.py +12 -0
- pythonlings/curriculum/exercises/recursion/recursion3.py +12 -0
- pythonlings/curriculum/exercises/recursion/recursion4.py +12 -0
- pythonlings/curriculum/exercises/recursion/recursion5.py +14 -0
- pythonlings/curriculum/exercises/recursion/recursion6.py +13 -0
- pythonlings/curriculum/exercises/recursion/recursion7.py +20 -0
- pythonlings/curriculum/exercises/recursion/recursion8.py +27 -0
- pythonlings/curriculum/exercises/regex/regex1.py +16 -0
- pythonlings/curriculum/exercises/regex/regex10.py +31 -0
- pythonlings/curriculum/exercises/regex/regex2.py +16 -0
- pythonlings/curriculum/exercises/regex/regex3.py +16 -0
- pythonlings/curriculum/exercises/regex/regex4.py +19 -0
- pythonlings/curriculum/exercises/regex/regex5.py +19 -0
- pythonlings/curriculum/exercises/regex/regex6.py +23 -0
- pythonlings/curriculum/exercises/regex/regex7.py +24 -0
- pythonlings/curriculum/exercises/regex/regex8.py +19 -0
- pythonlings/curriculum/exercises/regex/regex9.py +22 -0
- pythonlings/curriculum/exercises/sets/sets1.py +6 -0
- pythonlings/curriculum/exercises/sets/sets10.py +21 -0
- pythonlings/curriculum/exercises/sets/sets2.py +12 -0
- pythonlings/curriculum/exercises/sets/sets3.py +15 -0
- pythonlings/curriculum/exercises/sets/sets4.py +14 -0
- pythonlings/curriculum/exercises/sets/sets5.py +14 -0
- pythonlings/curriculum/exercises/sets/sets6.py +14 -0
- pythonlings/curriculum/exercises/sets/sets7.py +16 -0
- pythonlings/curriculum/exercises/sets/sets8.py +16 -0
- pythonlings/curriculum/exercises/sets/sets9.py +15 -0
- pythonlings/curriculum/exercises/strings/strings1.py +6 -0
- pythonlings/curriculum/exercises/strings/strings10.py +11 -0
- pythonlings/curriculum/exercises/strings/strings2.py +9 -0
- pythonlings/curriculum/exercises/strings/strings3.py +9 -0
- pythonlings/curriculum/exercises/strings/strings4.py +8 -0
- pythonlings/curriculum/exercises/strings/strings5.py +10 -0
- pythonlings/curriculum/exercises/strings/strings6.py +10 -0
- pythonlings/curriculum/exercises/strings/strings7.py +10 -0
- pythonlings/curriculum/exercises/strings/strings8.py +9 -0
- pythonlings/curriculum/exercises/strings/strings9.py +10 -0
- pythonlings/curriculum/exercises/testing/testing1.py +16 -0
- pythonlings/curriculum/exercises/testing/testing10.py +21 -0
- pythonlings/curriculum/exercises/testing/testing11.py +27 -0
- pythonlings/curriculum/exercises/testing/testing12.py +51 -0
- pythonlings/curriculum/exercises/testing/testing2.py +15 -0
- pythonlings/curriculum/exercises/testing/testing3.py +19 -0
- pythonlings/curriculum/exercises/testing/testing4.py +19 -0
- pythonlings/curriculum/exercises/testing/testing5.py +18 -0
- pythonlings/curriculum/exercises/testing/testing6.py +27 -0
- pythonlings/curriculum/exercises/testing/testing7.py +27 -0
- pythonlings/curriculum/exercises/testing/testing8.py +29 -0
- pythonlings/curriculum/exercises/testing/testing9.py +30 -0
- pythonlings/curriculum/exercises/tuples/tuples1.py +7 -0
- pythonlings/curriculum/exercises/tuples/tuples10.py +26 -0
- pythonlings/curriculum/exercises/tuples/tuples2.py +11 -0
- pythonlings/curriculum/exercises/tuples/tuples3.py +9 -0
- pythonlings/curriculum/exercises/tuples/tuples4.py +8 -0
- pythonlings/curriculum/exercises/tuples/tuples5.py +12 -0
- pythonlings/curriculum/exercises/tuples/tuples6.py +15 -0
- pythonlings/curriculum/exercises/tuples/tuples7.py +14 -0
- pythonlings/curriculum/exercises/tuples/tuples8.py +13 -0
- pythonlings/curriculum/exercises/tuples/tuples9.py +18 -0
- pythonlings/curriculum/exercises/type_hints/type_hints1.py +9 -0
- pythonlings/curriculum/exercises/type_hints/type_hints2.py +13 -0
- pythonlings/curriculum/exercises/type_hints/type_hints3.py +13 -0
- pythonlings/curriculum/exercises/type_hints/type_hints4.py +21 -0
- pythonlings/curriculum/exercises/type_hints/type_hints5.py +15 -0
- pythonlings/curriculum/exercises/type_hints/type_hints6.py +16 -0
- pythonlings/curriculum/exercises/type_hints/type_hints7.py +19 -0
- pythonlings/curriculum/exercises/type_hints/type_hints8.py +27 -0
- pythonlings/curriculum/exercises/variables/variables1.py +10 -0
- pythonlings/curriculum/exercises/variables/variables10.py +14 -0
- pythonlings/curriculum/exercises/variables/variables2.py +11 -0
- pythonlings/curriculum/exercises/variables/variables3.py +11 -0
- pythonlings/curriculum/exercises/variables/variables4.py +9 -0
- pythonlings/curriculum/exercises/variables/variables5.py +11 -0
- pythonlings/curriculum/exercises/variables/variables6.py +9 -0
- pythonlings/curriculum/exercises/variables/variables7.py +10 -0
- pythonlings/curriculum/exercises/variables/variables8.py +12 -0
- pythonlings/curriculum/exercises/variables/variables9.py +10 -0
- pythonlings/curriculum/info.toml +1755 -0
- pythonlings/curriculum/solutions/.keep +1 -0
- pythonlings/curriculum/solutions/_answers.py +1654 -0
- pythonlings/curriculum/solutions/async1.py +2 -0
- pythonlings/curriculum/solutions/async10.py +2 -0
- pythonlings/curriculum/solutions/async2.py +2 -0
- pythonlings/curriculum/solutions/async3.py +2 -0
- pythonlings/curriculum/solutions/async4.py +2 -0
- pythonlings/curriculum/solutions/async5.py +2 -0
- pythonlings/curriculum/solutions/async6.py +2 -0
- pythonlings/curriculum/solutions/async7.py +2 -0
- pythonlings/curriculum/solutions/async8.py +2 -0
- pythonlings/curriculum/solutions/async9.py +2 -0
- pythonlings/curriculum/solutions/classes1.py +2 -0
- pythonlings/curriculum/solutions/classes10.py +2 -0
- pythonlings/curriculum/solutions/classes11.py +2 -0
- pythonlings/curriculum/solutions/classes12.py +2 -0
- pythonlings/curriculum/solutions/classes2.py +2 -0
- pythonlings/curriculum/solutions/classes3.py +2 -0
- pythonlings/curriculum/solutions/classes4.py +2 -0
- pythonlings/curriculum/solutions/classes5.py +2 -0
- pythonlings/curriculum/solutions/classes6.py +2 -0
- pythonlings/curriculum/solutions/classes7.py +2 -0
- pythonlings/curriculum/solutions/classes8.py +2 -0
- pythonlings/curriculum/solutions/classes9.py +2 -0
- pythonlings/curriculum/solutions/collections1.py +2 -0
- pythonlings/curriculum/solutions/collections10.py +2 -0
- pythonlings/curriculum/solutions/collections2.py +2 -0
- pythonlings/curriculum/solutions/collections3.py +2 -0
- pythonlings/curriculum/solutions/collections4.py +2 -0
- pythonlings/curriculum/solutions/collections5.py +2 -0
- pythonlings/curriculum/solutions/collections6.py +2 -0
- pythonlings/curriculum/solutions/collections7.py +2 -0
- pythonlings/curriculum/solutions/collections8.py +2 -0
- pythonlings/curriculum/solutions/collections9.py +2 -0
- pythonlings/curriculum/solutions/comprehensions1.py +2 -0
- pythonlings/curriculum/solutions/comprehensions10.py +2 -0
- pythonlings/curriculum/solutions/comprehensions2.py +2 -0
- pythonlings/curriculum/solutions/comprehensions3.py +2 -0
- pythonlings/curriculum/solutions/comprehensions4.py +2 -0
- pythonlings/curriculum/solutions/comprehensions5.py +2 -0
- pythonlings/curriculum/solutions/comprehensions6.py +2 -0
- pythonlings/curriculum/solutions/comprehensions7.py +2 -0
- pythonlings/curriculum/solutions/comprehensions8.py +2 -0
- pythonlings/curriculum/solutions/comprehensions9.py +2 -0
- pythonlings/curriculum/solutions/conditionals1.py +2 -0
- pythonlings/curriculum/solutions/conditionals10.py +2 -0
- pythonlings/curriculum/solutions/conditionals2.py +2 -0
- pythonlings/curriculum/solutions/conditionals3.py +2 -0
- pythonlings/curriculum/solutions/conditionals4.py +2 -0
- pythonlings/curriculum/solutions/conditionals5.py +2 -0
- pythonlings/curriculum/solutions/conditionals6.py +2 -0
- pythonlings/curriculum/solutions/conditionals7.py +2 -0
- pythonlings/curriculum/solutions/conditionals8.py +2 -0
- pythonlings/curriculum/solutions/conditionals9.py +2 -0
- pythonlings/curriculum/solutions/context_managers1.py +2 -0
- pythonlings/curriculum/solutions/context_managers2.py +2 -0
- pythonlings/curriculum/solutions/context_managers3.py +2 -0
- pythonlings/curriculum/solutions/context_managers4.py +2 -0
- pythonlings/curriculum/solutions/context_managers5.py +2 -0
- pythonlings/curriculum/solutions/context_managers6.py +2 -0
- pythonlings/curriculum/solutions/context_managers7.py +2 -0
- pythonlings/curriculum/solutions/context_managers8.py +2 -0
- pythonlings/curriculum/solutions/dataclasses1.py +2 -0
- pythonlings/curriculum/solutions/dataclasses2.py +2 -0
- pythonlings/curriculum/solutions/dataclasses3.py +2 -0
- pythonlings/curriculum/solutions/dataclasses4.py +2 -0
- pythonlings/curriculum/solutions/dataclasses5.py +2 -0
- pythonlings/curriculum/solutions/dataclasses6.py +2 -0
- pythonlings/curriculum/solutions/dataclasses7.py +2 -0
- pythonlings/curriculum/solutions/dataclasses8.py +2 -0
- pythonlings/curriculum/solutions/datetime1.py +2 -0
- pythonlings/curriculum/solutions/datetime2.py +2 -0
- pythonlings/curriculum/solutions/datetime3.py +2 -0
- pythonlings/curriculum/solutions/datetime4.py +2 -0
- pythonlings/curriculum/solutions/datetime5.py +2 -0
- pythonlings/curriculum/solutions/datetime6.py +2 -0
- pythonlings/curriculum/solutions/datetime7.py +2 -0
- pythonlings/curriculum/solutions/datetime8.py +2 -0
- pythonlings/curriculum/solutions/decorators1.py +2 -0
- pythonlings/curriculum/solutions/decorators10.py +2 -0
- pythonlings/curriculum/solutions/decorators2.py +2 -0
- pythonlings/curriculum/solutions/decorators3.py +2 -0
- pythonlings/curriculum/solutions/decorators4.py +2 -0
- pythonlings/curriculum/solutions/decorators5.py +2 -0
- pythonlings/curriculum/solutions/decorators6.py +2 -0
- pythonlings/curriculum/solutions/decorators7.py +2 -0
- pythonlings/curriculum/solutions/decorators8.py +2 -0
- pythonlings/curriculum/solutions/decorators9.py +2 -0
- pythonlings/curriculum/solutions/dictionaries1.py +2 -0
- pythonlings/curriculum/solutions/dictionaries10.py +2 -0
- pythonlings/curriculum/solutions/dictionaries2.py +2 -0
- pythonlings/curriculum/solutions/dictionaries3.py +2 -0
- pythonlings/curriculum/solutions/dictionaries4.py +2 -0
- pythonlings/curriculum/solutions/dictionaries5.py +2 -0
- pythonlings/curriculum/solutions/dictionaries6.py +2 -0
- pythonlings/curriculum/solutions/dictionaries7.py +2 -0
- pythonlings/curriculum/solutions/dictionaries8.py +2 -0
- pythonlings/curriculum/solutions/dictionaries9.py +2 -0
- pythonlings/curriculum/solutions/enums1.py +2 -0
- pythonlings/curriculum/solutions/enums2.py +2 -0
- pythonlings/curriculum/solutions/enums3.py +2 -0
- pythonlings/curriculum/solutions/enums4.py +2 -0
- pythonlings/curriculum/solutions/enums5.py +2 -0
- pythonlings/curriculum/solutions/enums6.py +2 -0
- pythonlings/curriculum/solutions/exceptions1.py +2 -0
- pythonlings/curriculum/solutions/exceptions10.py +2 -0
- pythonlings/curriculum/solutions/exceptions2.py +2 -0
- pythonlings/curriculum/solutions/exceptions3.py +2 -0
- pythonlings/curriculum/solutions/exceptions4.py +2 -0
- pythonlings/curriculum/solutions/exceptions5.py +2 -0
- pythonlings/curriculum/solutions/exceptions6.py +2 -0
- pythonlings/curriculum/solutions/exceptions7.py +2 -0
- pythonlings/curriculum/solutions/exceptions8.py +2 -0
- pythonlings/curriculum/solutions/exceptions9.py +2 -0
- pythonlings/curriculum/solutions/file_io1.py +2 -0
- pythonlings/curriculum/solutions/file_io10.py +2 -0
- pythonlings/curriculum/solutions/file_io2.py +2 -0
- pythonlings/curriculum/solutions/file_io3.py +2 -0
- pythonlings/curriculum/solutions/file_io4.py +2 -0
- pythonlings/curriculum/solutions/file_io5.py +2 -0
- pythonlings/curriculum/solutions/file_io6.py +2 -0
- pythonlings/curriculum/solutions/file_io7.py +2 -0
- pythonlings/curriculum/solutions/file_io8.py +2 -0
- pythonlings/curriculum/solutions/file_io9.py +2 -0
- pythonlings/curriculum/solutions/functional1.py +2 -0
- pythonlings/curriculum/solutions/functional10.py +2 -0
- pythonlings/curriculum/solutions/functional2.py +2 -0
- pythonlings/curriculum/solutions/functional3.py +2 -0
- pythonlings/curriculum/solutions/functional4.py +2 -0
- pythonlings/curriculum/solutions/functional5.py +2 -0
- pythonlings/curriculum/solutions/functional6.py +2 -0
- pythonlings/curriculum/solutions/functional7.py +2 -0
- pythonlings/curriculum/solutions/functional8.py +2 -0
- pythonlings/curriculum/solutions/functional9.py +2 -0
- pythonlings/curriculum/solutions/functions1.py +2 -0
- pythonlings/curriculum/solutions/functions10.py +2 -0
- pythonlings/curriculum/solutions/functions2.py +2 -0
- pythonlings/curriculum/solutions/functions3.py +2 -0
- pythonlings/curriculum/solutions/functions4.py +2 -0
- pythonlings/curriculum/solutions/functions5.py +2 -0
- pythonlings/curriculum/solutions/functions6.py +2 -0
- pythonlings/curriculum/solutions/functions7.py +2 -0
- pythonlings/curriculum/solutions/functions8.py +2 -0
- pythonlings/curriculum/solutions/functions9.py +2 -0
- pythonlings/curriculum/solutions/generators1.py +2 -0
- pythonlings/curriculum/solutions/generators10.py +2 -0
- pythonlings/curriculum/solutions/generators2.py +2 -0
- pythonlings/curriculum/solutions/generators3.py +2 -0
- pythonlings/curriculum/solutions/generators4.py +2 -0
- pythonlings/curriculum/solutions/generators5.py +2 -0
- pythonlings/curriculum/solutions/generators6.py +2 -0
- pythonlings/curriculum/solutions/generators7.py +2 -0
- pythonlings/curriculum/solutions/generators8.py +2 -0
- pythonlings/curriculum/solutions/generators9.py +2 -0
- pythonlings/curriculum/solutions/itertools1.py +2 -0
- pythonlings/curriculum/solutions/itertools2.py +2 -0
- pythonlings/curriculum/solutions/itertools3.py +2 -0
- pythonlings/curriculum/solutions/itertools4.py +2 -0
- pythonlings/curriculum/solutions/itertools5.py +2 -0
- pythonlings/curriculum/solutions/itertools6.py +2 -0
- pythonlings/curriculum/solutions/itertools7.py +2 -0
- pythonlings/curriculum/solutions/itertools8.py +2 -0
- pythonlings/curriculum/solutions/json1.py +2 -0
- pythonlings/curriculum/solutions/json2.py +2 -0
- pythonlings/curriculum/solutions/json3.py +2 -0
- pythonlings/curriculum/solutions/json4.py +2 -0
- pythonlings/curriculum/solutions/json5.py +2 -0
- pythonlings/curriculum/solutions/json6.py +2 -0
- pythonlings/curriculum/solutions/json7.py +2 -0
- pythonlings/curriculum/solutions/json8.py +2 -0
- pythonlings/curriculum/solutions/lists1.py +2 -0
- pythonlings/curriculum/solutions/lists10.py +2 -0
- pythonlings/curriculum/solutions/lists2.py +2 -0
- pythonlings/curriculum/solutions/lists3.py +2 -0
- pythonlings/curriculum/solutions/lists4.py +2 -0
- pythonlings/curriculum/solutions/lists5.py +2 -0
- pythonlings/curriculum/solutions/lists6.py +2 -0
- pythonlings/curriculum/solutions/lists7.py +2 -0
- pythonlings/curriculum/solutions/lists8.py +2 -0
- pythonlings/curriculum/solutions/lists9.py +2 -0
- pythonlings/curriculum/solutions/loops1.py +2 -0
- pythonlings/curriculum/solutions/loops10.py +2 -0
- pythonlings/curriculum/solutions/loops2.py +2 -0
- pythonlings/curriculum/solutions/loops3.py +2 -0
- pythonlings/curriculum/solutions/loops4.py +2 -0
- pythonlings/curriculum/solutions/loops5.py +2 -0
- pythonlings/curriculum/solutions/loops6.py +2 -0
- pythonlings/curriculum/solutions/loops7.py +2 -0
- pythonlings/curriculum/solutions/loops8.py +2 -0
- pythonlings/curriculum/solutions/loops9.py +2 -0
- pythonlings/curriculum/solutions/modules1.py +2 -0
- pythonlings/curriculum/solutions/modules2.py +2 -0
- pythonlings/curriculum/solutions/modules3.py +2 -0
- pythonlings/curriculum/solutions/modules4.py +2 -0
- pythonlings/curriculum/solutions/modules5.py +2 -0
- pythonlings/curriculum/solutions/modules6.py +2 -0
- pythonlings/curriculum/solutions/modules7.py +2 -0
- pythonlings/curriculum/solutions/modules8.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced1.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced10.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced11.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced12.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced2.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced3.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced4.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced5.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced6.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced7.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced8.py +2 -0
- pythonlings/curriculum/solutions/oop_advanced9.py +2 -0
- pythonlings/curriculum/solutions/pathlib1.py +2 -0
- pythonlings/curriculum/solutions/pathlib2.py +2 -0
- pythonlings/curriculum/solutions/pathlib3.py +2 -0
- pythonlings/curriculum/solutions/pathlib4.py +2 -0
- pythonlings/curriculum/solutions/pathlib5.py +2 -0
- pythonlings/curriculum/solutions/pathlib6.py +2 -0
- pythonlings/curriculum/solutions/recursion1.py +2 -0
- pythonlings/curriculum/solutions/recursion2.py +2 -0
- pythonlings/curriculum/solutions/recursion3.py +2 -0
- pythonlings/curriculum/solutions/recursion4.py +2 -0
- pythonlings/curriculum/solutions/recursion5.py +2 -0
- pythonlings/curriculum/solutions/recursion6.py +2 -0
- pythonlings/curriculum/solutions/recursion7.py +2 -0
- pythonlings/curriculum/solutions/recursion8.py +2 -0
- pythonlings/curriculum/solutions/regex1.py +2 -0
- pythonlings/curriculum/solutions/regex10.py +2 -0
- pythonlings/curriculum/solutions/regex2.py +2 -0
- pythonlings/curriculum/solutions/regex3.py +2 -0
- pythonlings/curriculum/solutions/regex4.py +2 -0
- pythonlings/curriculum/solutions/regex5.py +2 -0
- pythonlings/curriculum/solutions/regex6.py +2 -0
- pythonlings/curriculum/solutions/regex7.py +2 -0
- pythonlings/curriculum/solutions/regex8.py +2 -0
- pythonlings/curriculum/solutions/regex9.py +2 -0
- pythonlings/curriculum/solutions/sets1.py +2 -0
- pythonlings/curriculum/solutions/sets10.py +2 -0
- pythonlings/curriculum/solutions/sets2.py +2 -0
- pythonlings/curriculum/solutions/sets3.py +2 -0
- pythonlings/curriculum/solutions/sets4.py +2 -0
- pythonlings/curriculum/solutions/sets5.py +2 -0
- pythonlings/curriculum/solutions/sets6.py +2 -0
- pythonlings/curriculum/solutions/sets7.py +2 -0
- pythonlings/curriculum/solutions/sets8.py +2 -0
- pythonlings/curriculum/solutions/sets9.py +2 -0
- pythonlings/curriculum/solutions/strings1.py +2 -0
- pythonlings/curriculum/solutions/strings10.py +2 -0
- pythonlings/curriculum/solutions/strings2.py +2 -0
- pythonlings/curriculum/solutions/strings3.py +2 -0
- pythonlings/curriculum/solutions/strings4.py +2 -0
- pythonlings/curriculum/solutions/strings5.py +2 -0
- pythonlings/curriculum/solutions/strings6.py +2 -0
- pythonlings/curriculum/solutions/strings7.py +2 -0
- pythonlings/curriculum/solutions/strings8.py +2 -0
- pythonlings/curriculum/solutions/strings9.py +2 -0
- pythonlings/curriculum/solutions/testing1.py +2 -0
- pythonlings/curriculum/solutions/testing10.py +2 -0
- pythonlings/curriculum/solutions/testing11.py +2 -0
- pythonlings/curriculum/solutions/testing12.py +2 -0
- pythonlings/curriculum/solutions/testing2.py +2 -0
- pythonlings/curriculum/solutions/testing3.py +2 -0
- pythonlings/curriculum/solutions/testing4.py +2 -0
- pythonlings/curriculum/solutions/testing5.py +2 -0
- pythonlings/curriculum/solutions/testing6.py +2 -0
- pythonlings/curriculum/solutions/testing7.py +2 -0
- pythonlings/curriculum/solutions/testing8.py +2 -0
- pythonlings/curriculum/solutions/testing9.py +2 -0
- pythonlings/curriculum/solutions/tuples1.py +2 -0
- pythonlings/curriculum/solutions/tuples10.py +2 -0
- pythonlings/curriculum/solutions/tuples2.py +2 -0
- pythonlings/curriculum/solutions/tuples3.py +2 -0
- pythonlings/curriculum/solutions/tuples4.py +2 -0
- pythonlings/curriculum/solutions/tuples5.py +2 -0
- pythonlings/curriculum/solutions/tuples6.py +2 -0
- pythonlings/curriculum/solutions/tuples7.py +2 -0
- pythonlings/curriculum/solutions/tuples8.py +2 -0
- pythonlings/curriculum/solutions/tuples9.py +2 -0
- pythonlings/curriculum/solutions/type_hints1.py +2 -0
- pythonlings/curriculum/solutions/type_hints2.py +2 -0
- pythonlings/curriculum/solutions/type_hints3.py +2 -0
- pythonlings/curriculum/solutions/type_hints4.py +2 -0
- pythonlings/curriculum/solutions/type_hints5.py +2 -0
- pythonlings/curriculum/solutions/type_hints6.py +2 -0
- pythonlings/curriculum/solutions/type_hints7.py +2 -0
- pythonlings/curriculum/solutions/type_hints8.py +2 -0
- pythonlings/curriculum/solutions/variables1.py +2 -0
- pythonlings/curriculum/solutions/variables10.py +2 -0
- pythonlings/curriculum/solutions/variables2.py +2 -0
- pythonlings/curriculum/solutions/variables3.py +2 -0
- pythonlings/curriculum/solutions/variables4.py +2 -0
- pythonlings/curriculum/solutions/variables5.py +2 -0
- pythonlings/curriculum/solutions/variables6.py +2 -0
- pythonlings/curriculum/solutions/variables7.py +2 -0
- pythonlings/curriculum/solutions/variables8.py +2 -0
- pythonlings/curriculum/solutions/variables9.py +2 -0
- pythonlings/docs/NOTICE.md +9 -0
- pythonlings/docs/__init__.py +1 -0
- pythonlings/docs/index.json +160 -0
- pythonlings/docs/topics/__init__.py +1 -0
- pythonlings/docs/topics/async.md +97 -0
- pythonlings/docs/topics/classes.md +97 -0
- pythonlings/docs/topics/collections.md +96 -0
- pythonlings/docs/topics/comprehensions.md +97 -0
- pythonlings/docs/topics/conditionals.md +88 -0
- pythonlings/docs/topics/context_managers.md +97 -0
- pythonlings/docs/topics/dataclasses.md +97 -0
- pythonlings/docs/topics/datetime.md +97 -0
- pythonlings/docs/topics/decorators.md +91 -0
- pythonlings/docs/topics/dictionaries.md +96 -0
- pythonlings/docs/topics/enums.md +96 -0
- pythonlings/docs/topics/exceptions.md +96 -0
- pythonlings/docs/topics/file_io.md +96 -0
- pythonlings/docs/topics/functional.md +96 -0
- pythonlings/docs/topics/functions.md +97 -0
- pythonlings/docs/topics/generators.md +97 -0
- pythonlings/docs/topics/itertools.md +96 -0
- pythonlings/docs/topics/json.md +97 -0
- pythonlings/docs/topics/lists.md +97 -0
- pythonlings/docs/topics/loops.md +95 -0
- pythonlings/docs/topics/modules.md +97 -0
- pythonlings/docs/topics/oop_advanced.md +71 -0
- pythonlings/docs/topics/pathlib.md +79 -0
- pythonlings/docs/topics/recursion.md +73 -0
- pythonlings/docs/topics/regex.md +96 -0
- pythonlings/docs/topics/sets.md +97 -0
- pythonlings/docs/topics/strings.md +96 -0
- pythonlings/docs/topics/testing.md +97 -0
- pythonlings/docs/topics/tuples.md +97 -0
- pythonlings/docs/topics/type_hints.md +97 -0
- pythonlings/docs/topics/variables.md +97 -0
- pythonlings/pythonlings.tcss +123 -0
- pythonlings/screens/__init__.py +0 -0
- pythonlings/screens/docs.py +93 -0
- pythonlings/screens/topic_picker.py +107 -0
- pythonlings/screens/track.py +234 -0
- pythonlings/widgets/__init__.py +0 -0
- pythonlings/widgets/editor_pane.py +33 -0
- pythonlings/widgets/exercise_tree.py +33 -0
- pythonlings/widgets/output_panel.py +180 -0
- pythonlings/widgets/progress.py +15 -0
- pythonlings-0.3.0.dist-info/METADATA +259 -0
- pythonlings-0.3.0.dist-info/RECORD +942 -0
- pythonlings-0.3.0.dist-info/WHEEL +4 -0
- pythonlings-0.3.0.dist-info/entry_points.txt +2 -0
- pythonlings-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Exercise: Collections 4
|
|
2
|
+
# -----------------------
|
|
3
|
+
# I AM NOT DONE
|
|
4
|
+
#
|
|
5
|
+
# `defaultdict(list)` is great for grouping: every new key starts with
|
|
6
|
+
# an empty list so you can append without checking first.
|
|
7
|
+
#
|
|
8
|
+
# Group the students below by their grade letter.
|
|
9
|
+
# `by_grade` should be a `defaultdict(list)` where each key is a grade
|
|
10
|
+
# letter and the value is a list of student names with that grade,
|
|
11
|
+
# in the order they appear in `students`.
|
|
12
|
+
|
|
13
|
+
from collections import defaultdict
|
|
14
|
+
|
|
15
|
+
students = [
|
|
16
|
+
("Alice", "A"),
|
|
17
|
+
("Bob", "B"),
|
|
18
|
+
("Carol", "A"),
|
|
19
|
+
("Dave", "C"),
|
|
20
|
+
("Eve", "B"),
|
|
21
|
+
("Frank", "A"),
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
by_grade = ???
|
|
25
|
+
for name, grade in students:
|
|
26
|
+
???
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Exercise: Collections 5
|
|
2
|
+
# -----------------------
|
|
3
|
+
# I AM NOT DONE
|
|
4
|
+
#
|
|
5
|
+
# `namedtuple` creates a lightweight class whose instances are tuples
|
|
6
|
+
# with named fields — readable without index magic.
|
|
7
|
+
#
|
|
8
|
+
# Define a namedtuple type called `Point` with fields `x` and `y`.
|
|
9
|
+
# Then create an instance `p` with x=3 and y=4.
|
|
10
|
+
|
|
11
|
+
from collections import namedtuple
|
|
12
|
+
|
|
13
|
+
Point = ???
|
|
14
|
+
p = ???
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Exercise: Collections 6
|
|
2
|
+
# -----------------------
|
|
3
|
+
# I AM NOT DONE
|
|
4
|
+
#
|
|
5
|
+
# Named-tuple fields can be accessed by name OR by index, just like a
|
|
6
|
+
# regular tuple. They also support `._replace()` to build a modified copy.
|
|
7
|
+
#
|
|
8
|
+
# A `Card` namedtuple with fields `rank` and `suit` is defined for you.
|
|
9
|
+
# 1. Create `card` — the King of Spades (rank="K", suit="spades").
|
|
10
|
+
# 2. Create `upgraded` by replacing the rank of `card` with "A"
|
|
11
|
+
# using `card._replace(...)`.
|
|
12
|
+
|
|
13
|
+
from collections import namedtuple
|
|
14
|
+
|
|
15
|
+
Card = namedtuple("Card", ["rank", "suit"])
|
|
16
|
+
|
|
17
|
+
card = ???
|
|
18
|
+
upgraded = ???
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Exercise: Collections 7
|
|
2
|
+
# -----------------------
|
|
3
|
+
# I AM NOT DONE
|
|
4
|
+
#
|
|
5
|
+
# `deque` (double-ended queue) supports O(1) appends and pops from
|
|
6
|
+
# BOTH ends — unlike a list, which is O(n) for the left end.
|
|
7
|
+
#
|
|
8
|
+
# Starting from an empty deque `d`:
|
|
9
|
+
# 1. appendleft(1) — push to the left
|
|
10
|
+
# 2. append(2) — push to the right
|
|
11
|
+
# 3. appendleft(0) — push to the left again
|
|
12
|
+
# 4. Store the result of pop() in `right_val` (removes from right)
|
|
13
|
+
# 5. Store the result of popleft() in `left_val` (removes from left)
|
|
14
|
+
|
|
15
|
+
from collections import deque
|
|
16
|
+
|
|
17
|
+
d = deque()
|
|
18
|
+
???
|
|
19
|
+
right_val = ???
|
|
20
|
+
left_val = ???
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Exercise: Collections 8
|
|
2
|
+
# -----------------------
|
|
3
|
+
# I AM NOT DONE
|
|
4
|
+
#
|
|
5
|
+
# A deque makes an efficient FIFO queue: enqueue with `append` (right)
|
|
6
|
+
# and dequeue with `popleft` (left).
|
|
7
|
+
#
|
|
8
|
+
# Simulate a print queue:
|
|
9
|
+
# - Enqueue jobs "doc1", "doc2", "doc3" (in that order).
|
|
10
|
+
# - Dequeue them one by one into `first`, `second`, `third`.
|
|
11
|
+
# The deque `queue` should be empty afterwards.
|
|
12
|
+
|
|
13
|
+
from collections import deque
|
|
14
|
+
|
|
15
|
+
queue = deque()
|
|
16
|
+
|
|
17
|
+
# enqueue three jobs
|
|
18
|
+
???
|
|
19
|
+
|
|
20
|
+
# dequeue in FIFO order
|
|
21
|
+
first = ???
|
|
22
|
+
second = ???
|
|
23
|
+
third = ???
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Exercise: Collections 9
|
|
2
|
+
# -----------------------
|
|
3
|
+
# I AM NOT DONE
|
|
4
|
+
#
|
|
5
|
+
# Counter supports arithmetic:
|
|
6
|
+
# c1 + c2 — adds counts element-wise
|
|
7
|
+
# c1 - c2 — subtracts counts, dropping non-positive results
|
|
8
|
+
#
|
|
9
|
+
# Two inventory snapshots are given.
|
|
10
|
+
# 1. Store in `combined` the element-wise sum of `monday` and `tuesday`.
|
|
11
|
+
# 2. Store in `remainder` the result of subtracting `sold` from `combined`.
|
|
12
|
+
# (Only items with a positive remaining count are kept.)
|
|
13
|
+
|
|
14
|
+
from collections import Counter
|
|
15
|
+
|
|
16
|
+
monday = Counter({"apple": 5, "banana": 3, "cherry": 2})
|
|
17
|
+
tuesday = Counter({"apple": 2, "banana": 4, "date": 1})
|
|
18
|
+
sold = Counter({"apple": 4, "banana": 5, "cherry": 1})
|
|
19
|
+
|
|
20
|
+
combined = ???
|
|
21
|
+
remainder = ???
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Exercise: Comprehensions 1
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension to build `numbers`: the integers 0 through 4
|
|
5
|
+
# (i.e. 0, 1, 2, 3, 4) collected into a list.
|
|
6
|
+
#
|
|
7
|
+
# A list comprehension has the form: [expr for item in iterable]
|
|
8
|
+
# Example: [x for x in range(3)] → [0, 1, 2]
|
|
9
|
+
|
|
10
|
+
numbers = ???
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Exercise: Comprehensions 10
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Build a lookup table `word_index` using a dict comprehension that maps each
|
|
5
|
+
# word in `words` to its position (index) in the list.
|
|
6
|
+
#
|
|
7
|
+
# `enumerate(iterable)` yields (index, value) pairs — use it with a dict
|
|
8
|
+
# comprehension to pair each word with its position:
|
|
9
|
+
# {word: idx for idx, word in enumerate(words)}
|
|
10
|
+
#
|
|
11
|
+
# Expected: {"apple": 0, "banana": 1, "cherry": 2, "date": 3}
|
|
12
|
+
|
|
13
|
+
words = ["apple", "banana", "cherry", "date"]
|
|
14
|
+
|
|
15
|
+
word_index = ???
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Exercise: Comprehensions 2
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension with an `if` filter to build `evens`: only the
|
|
5
|
+
# even numbers from `values`.
|
|
6
|
+
#
|
|
7
|
+
# A filtered comprehension: [expr for item in iterable if condition]
|
|
8
|
+
# Example: [x for x in range(6) if x > 3] → [4, 5]
|
|
9
|
+
|
|
10
|
+
values = [1, 2, 3, 4, 5, 6, 7, 8]
|
|
11
|
+
|
|
12
|
+
evens = ???
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Exercise: Comprehensions 3
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension with a transform to build `doubled`: each number
|
|
5
|
+
# in `values` multiplied by 2.
|
|
6
|
+
#
|
|
7
|
+
# Transform the expression, not just the item:
|
|
8
|
+
# Example: [x * 3 for x in [1, 2, 3]] → [3, 6, 9]
|
|
9
|
+
|
|
10
|
+
values = [1, 2, 3, 4, 5]
|
|
11
|
+
|
|
12
|
+
doubled = ???
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Exercise: Comprehensions 4
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension with two `for` clauses (a nested loop) to build
|
|
5
|
+
# `pairs`: every (row, col) tuple where row is in `rows` and col is in `cols`.
|
|
6
|
+
#
|
|
7
|
+
# Nested-loop comprehension: [expr for a in A for b in B]
|
|
8
|
+
# Example: [(x, y) for x in [1, 2] for y in ['a', 'b']]
|
|
9
|
+
# → [(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b')]
|
|
10
|
+
|
|
11
|
+
rows = [0, 1]
|
|
12
|
+
cols = [0, 1, 2]
|
|
13
|
+
|
|
14
|
+
pairs = ???
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Exercise: Comprehensions 5
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a dict comprehension to build `squared`: a mapping from each number in
|
|
5
|
+
# `numbers` to its square.
|
|
6
|
+
#
|
|
7
|
+
# A dict comprehension: {key_expr: val_expr for item in iterable}
|
|
8
|
+
# Example: {x: x**2 for x in [1, 2, 3]} → {1: 1, 2: 4, 3: 9}
|
|
9
|
+
|
|
10
|
+
numbers = [1, 2, 3, 4, 5]
|
|
11
|
+
|
|
12
|
+
squared = ???
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Exercise: Comprehensions 6
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a set comprehension to build `unique_lengths`: the set of distinct word
|
|
5
|
+
# lengths in `words`.
|
|
6
|
+
#
|
|
7
|
+
# A set comprehension: {expr for item in iterable}
|
|
8
|
+
# Example: {len(w) for w in ["hi", "hey", "yo"]} → {2, 3}
|
|
9
|
+
|
|
10
|
+
words = ["apple", "bat", "car", "dog", "elephant", "fig"]
|
|
11
|
+
|
|
12
|
+
unique_lengths = ???
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Exercise: Comprehensions 7
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension over the characters of a string to build `vowels`:
|
|
5
|
+
# a list of every vowel (a, e, i, o, u) found in `sentence` (lowercase).
|
|
6
|
+
#
|
|
7
|
+
# You can iterate over a string character by character:
|
|
8
|
+
# Example: [c for c in "hello" if c in "aeiou"] → ['e', 'o']
|
|
9
|
+
|
|
10
|
+
sentence = "list comprehensions are quite powerful"
|
|
11
|
+
|
|
12
|
+
vowels = ???
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Exercise: Comprehensions 8
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension with a conditional expression (ternary) to build
|
|
5
|
+
# `labels`: for each number in `values`, use "even" if the number is even,
|
|
6
|
+
# otherwise use "odd".
|
|
7
|
+
#
|
|
8
|
+
# Conditional expression inside a comprehension:
|
|
9
|
+
# [value_if_true if condition else value_if_false for item in iterable]
|
|
10
|
+
# Example: ["pos" if x > 0 else "non-pos" for x in [-1, 2, 0]]
|
|
11
|
+
# → ['non-pos', 'pos', 'non-pos']
|
|
12
|
+
|
|
13
|
+
values = [1, 2, 3, 4, 5, 6]
|
|
14
|
+
|
|
15
|
+
labels = ???
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Exercise: Comprehensions 9
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a list comprehension to flatten `matrix` (a list of lists) into a single
|
|
5
|
+
# list called `flat`.
|
|
6
|
+
#
|
|
7
|
+
# Flattening with a comprehension uses two `for` clauses:
|
|
8
|
+
# [item for sublist in outer for item in sublist]
|
|
9
|
+
# Example: [[1, 2], [3, 4]] → [1, 2, 3, 4]
|
|
10
|
+
|
|
11
|
+
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
|
12
|
+
|
|
13
|
+
flat = ???
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Exercise: Conditionals 1
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Python's simplest conditional: if the condition is True, the indented
|
|
5
|
+
# block runs; otherwise nothing happens.
|
|
6
|
+
#
|
|
7
|
+
# `is_sunny` is True. Write an `if` statement so that `message` is set
|
|
8
|
+
# to "Let's go outside!" when `is_sunny` is True.
|
|
9
|
+
# Leave `message` as the empty string "" before the if-block.
|
|
10
|
+
|
|
11
|
+
is_sunny = True
|
|
12
|
+
message = ""
|
|
13
|
+
|
|
14
|
+
if ???:
|
|
15
|
+
message = "Let's go outside!"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Exercise: Conditionals 10
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Putting it all together: classify a number using several conditions.
|
|
5
|
+
#
|
|
6
|
+
# Complete `classify(n)` so it returns:
|
|
7
|
+
# "large positive" when n > 100
|
|
8
|
+
# "small positive" when n > 0 (and not > 100)
|
|
9
|
+
# "zero" when n == 0
|
|
10
|
+
# "small negative" when n >= -100 (and not 0 or positive)
|
|
11
|
+
# "large negative" when n < -100
|
|
12
|
+
#
|
|
13
|
+
# Use an if / elif / elif / elif / else chain.
|
|
14
|
+
|
|
15
|
+
def classify(n):
|
|
16
|
+
if ???:
|
|
17
|
+
return "large positive"
|
|
18
|
+
???
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Exercise: Conditionals 2
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# An if/else gives two branches: one when the condition is True,
|
|
5
|
+
# another when it is False.
|
|
6
|
+
#
|
|
7
|
+
# Complete the function `sign(n)` so it returns "positive" when n > 0
|
|
8
|
+
# and "non-positive" otherwise.
|
|
9
|
+
|
|
10
|
+
def sign(n):
|
|
11
|
+
if n > 0:
|
|
12
|
+
return "positive"
|
|
13
|
+
???
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Exercise: Conditionals 3
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# `elif` lets you chain multiple conditions. Python tests them in order
|
|
5
|
+
# and runs the first branch whose condition is True.
|
|
6
|
+
#
|
|
7
|
+
# Complete `grade(score)` so it returns:
|
|
8
|
+
# "A" for score >= 90
|
|
9
|
+
# "B" for score >= 80
|
|
10
|
+
# "C" for score >= 70
|
|
11
|
+
# "F" for anything below 70
|
|
12
|
+
|
|
13
|
+
def grade(score):
|
|
14
|
+
if score >= 90:
|
|
15
|
+
return "A"
|
|
16
|
+
# add the remaining elif / else branches
|
|
17
|
+
|
|
18
|
+
return "F"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Exercise: Conditionals 4
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Python comparison operators: <, <=, >, >=, ==, !=
|
|
5
|
+
# == equal to != not equal to
|
|
6
|
+
# < less than <= less than or equal
|
|
7
|
+
# > greater than >= greater than or equal
|
|
8
|
+
#
|
|
9
|
+
# Complete `compare(a, b)` so it returns:
|
|
10
|
+
# "less" when a < b
|
|
11
|
+
# "equal" when a == b
|
|
12
|
+
# "greater" when a > b
|
|
13
|
+
|
|
14
|
+
def compare(a, b):
|
|
15
|
+
if a ??? b:
|
|
16
|
+
return "less"
|
|
17
|
+
elif a ??? b:
|
|
18
|
+
return "equal"
|
|
19
|
+
else:
|
|
20
|
+
return "greater"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Exercise: Conditionals 5
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Boolean operators combine conditions:
|
|
5
|
+
# `and` — True only when BOTH sides are True
|
|
6
|
+
# `or` — True when AT LEAST ONE side is True
|
|
7
|
+
#
|
|
8
|
+
# Complete `can_ride(height, has_ticket)` so it returns True only when
|
|
9
|
+
# the rider is at least 120 cm tall AND has a ticket.
|
|
10
|
+
# Complete `gets_discount(is_student, is_senior)` so it returns True
|
|
11
|
+
# when the person is a student OR a senior.
|
|
12
|
+
|
|
13
|
+
def can_ride(height, has_ticket):
|
|
14
|
+
return height >= 120 ??? has_ticket
|
|
15
|
+
|
|
16
|
+
def gets_discount(is_student, is_senior):
|
|
17
|
+
return is_student ??? is_senior
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Exercise: Conditionals 6
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# `not` flips a boolean: `not True` is False, `not False` is True.
|
|
5
|
+
# It is useful when you want to act on the absence of something.
|
|
6
|
+
#
|
|
7
|
+
# Complete `is_closed(is_open)` so it returns True when the shop is NOT open.
|
|
8
|
+
# Complete `neither_zero(a, b)` so it returns True when NEITHER a nor b is 0.
|
|
9
|
+
# Hint: use `not` in both functions.
|
|
10
|
+
|
|
11
|
+
def is_closed(is_open):
|
|
12
|
+
return ???
|
|
13
|
+
|
|
14
|
+
def neither_zero(a, b):
|
|
15
|
+
return ???
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Exercise: Conditionals 7
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Nested `if` statements let you check a second condition only after
|
|
5
|
+
# a first condition has already passed.
|
|
6
|
+
#
|
|
7
|
+
# Complete `ticket_price(age, is_member)` using nested if/else:
|
|
8
|
+
# - Under 5 years old => free (0)
|
|
9
|
+
# - 5 or older AND a member => 8
|
|
10
|
+
# - 5 or older AND NOT a member => 12
|
|
11
|
+
|
|
12
|
+
def ticket_price(age, is_member):
|
|
13
|
+
if age < 5:
|
|
14
|
+
return 0
|
|
15
|
+
else:
|
|
16
|
+
if ???:
|
|
17
|
+
return 8
|
|
18
|
+
???
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Exercise: Conditionals 8
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Python has "truthiness": values can be used directly in conditions
|
|
5
|
+
# without an explicit == check.
|
|
6
|
+
#
|
|
7
|
+
# Falsy values (treated as False in a condition):
|
|
8
|
+
# 0, 0.0, "", [], {}, None
|
|
9
|
+
# Everything else is truthy.
|
|
10
|
+
#
|
|
11
|
+
# Complete `describe(value)` so it returns:
|
|
12
|
+
# "empty" when value is falsy
|
|
13
|
+
# "has content" when value is truthy
|
|
14
|
+
#
|
|
15
|
+
# Do NOT use == in your condition — use `if value` directly.
|
|
16
|
+
|
|
17
|
+
def describe(value):
|
|
18
|
+
if ???:
|
|
19
|
+
return "has content"
|
|
20
|
+
???
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Exercise: Conditionals 9
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# The ternary (conditional) expression lets you pick a value in one line:
|
|
5
|
+
#
|
|
6
|
+
# result = value_if_true if condition else value_if_false
|
|
7
|
+
#
|
|
8
|
+
# Complete `absolute(n)` so it returns n when n >= 0, and -n otherwise.
|
|
9
|
+
# Write it as a single return statement using a ternary expression.
|
|
10
|
+
|
|
11
|
+
def absolute(n):
|
|
12
|
+
return ???
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Exercise: Context Managers 1
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Use a `with` statement to open `data_path` for writing and write the
|
|
5
|
+
# text "hello, context!" to it. The with-block should handle opening
|
|
6
|
+
# and closing automatically — do NOT call .close() yourself.
|
|
7
|
+
#
|
|
8
|
+
# Hint: `with open(path, "w") as f:` opens the file; call `f.write(text)`
|
|
9
|
+
# inside the block.
|
|
10
|
+
|
|
11
|
+
import tempfile
|
|
12
|
+
|
|
13
|
+
data_path = tempfile.mktemp()
|
|
14
|
+
|
|
15
|
+
# Replace the bare open/write/close below with a with-statement.
|
|
16
|
+
f = open(data_path, "w")
|
|
17
|
+
f.write("hello, context!")
|
|
18
|
+
# Bug: .close() is missing — but the real fix is to use `with`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Exercise: Context Managers 2
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# After the with-block finishes, the file object should be closed
|
|
5
|
+
# automatically. The code below opens a file WITHOUT a with-statement,
|
|
6
|
+
# so `f.closed` is False after the write.
|
|
7
|
+
#
|
|
8
|
+
# Fix it: replace the bare open/write/close sequence with a with-statement
|
|
9
|
+
# that opens `data_path` for writing and writes "closed check".
|
|
10
|
+
# After the with-block, `f` must be the file object and `f.closed` must be True.
|
|
11
|
+
|
|
12
|
+
import tempfile
|
|
13
|
+
|
|
14
|
+
data_path = tempfile.mktemp()
|
|
15
|
+
|
|
16
|
+
# Bug: no with-statement — the file stays open until garbage-collected.
|
|
17
|
+
f = open(data_path, "w")
|
|
18
|
+
f.write("closed check")
|
|
19
|
+
# .close() is intentionally omitted to illustrate the problem.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Exercise: Context Managers 3
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# Give the `Timer` class context-manager support so `with Timer() as t:`
|
|
5
|
+
# works.
|
|
6
|
+
#
|
|
7
|
+
# * `__enter__` must return the instance (self).
|
|
8
|
+
# * `__exit__` must set `self.finished` to True.
|
|
9
|
+
# Both methods take the standard three exception parameters after self.
|
|
10
|
+
#
|
|
11
|
+
# Hint: `def __exit__(self, exc_type, exc_val, exc_tb):` — set the flag,
|
|
12
|
+
# then return None (or False) so exceptions propagate normally.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Timer:
|
|
16
|
+
def __init__(self):
|
|
17
|
+
self.finished = False
|
|
18
|
+
|
|
19
|
+
# Bug: __enter__ and __exit__ are missing — add them.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
t = Timer()
|
|
23
|
+
with t:
|
|
24
|
+
pass
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Exercise: Context Managers 4
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# `ManagedList` wraps a list and uses `__exit__` to do cleanup.
|
|
5
|
+
# When the with-block exits normally, `__exit__` should append the
|
|
6
|
+
# string "done" to `self.log`.
|
|
7
|
+
#
|
|
8
|
+
# The `__enter__` method is already written. Complete `__exit__` so
|
|
9
|
+
# that it appends "done" to `self.log` and returns None.
|
|
10
|
+
#
|
|
11
|
+
# Hint: `def __exit__(self, exc_type, exc_val, exc_tb): self.log.append("done")`
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ManagedList:
|
|
15
|
+
def __init__(self):
|
|
16
|
+
self.items = []
|
|
17
|
+
self.log = []
|
|
18
|
+
|
|
19
|
+
def __enter__(self):
|
|
20
|
+
return self
|
|
21
|
+
|
|
22
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
23
|
+
# Bug: cleanup is missing — append "done" to self.log.
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
ml = ManagedList()
|
|
28
|
+
with ml as resource:
|
|
29
|
+
resource.items.append(1)
|
|
30
|
+
resource.items.append(2)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Exercise: Context Managers 5
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# `__enter__` can return any value; that value becomes the target of the
|
|
5
|
+
# `as` clause. Fix `DatabaseConnection` so that `with db as conn:` gives
|
|
6
|
+
# the caller a dict that they can use like a connection.
|
|
7
|
+
#
|
|
8
|
+
# `__enter__` should return `self.connection` (the dict already set up in
|
|
9
|
+
# `__init__`). `__exit__` should set `self.open` to False.
|
|
10
|
+
#
|
|
11
|
+
# Hint: `def __enter__(self): return self.connection`
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DatabaseConnection:
|
|
15
|
+
def __init__(self, dsn):
|
|
16
|
+
self.dsn = dsn
|
|
17
|
+
self.open = True
|
|
18
|
+
self.connection = {"dsn": dsn, "active": True}
|
|
19
|
+
|
|
20
|
+
def __enter__(self):
|
|
21
|
+
# Bug: returns None instead of self.connection.
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
25
|
+
self.open = False
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
db = DatabaseConnection("sqlite:///:memory:")
|
|
29
|
+
with db as conn:
|
|
30
|
+
result = conn
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Exercise: Context Managers 6
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# `contextlib.contextmanager` turns a generator function into a context
|
|
5
|
+
# manager. Write the body of `managed_counter` so it:
|
|
6
|
+
# 1. Creates a list `counter = []` before the yield.
|
|
7
|
+
# 2. Yields `counter` (the `as` target gets this list).
|
|
8
|
+
# 3. Appends the string "finished" to `counter` after the yield.
|
|
9
|
+
#
|
|
10
|
+
# The `@contextmanager` decorator and the function signature are already
|
|
11
|
+
# provided. Only fill in the body.
|
|
12
|
+
#
|
|
13
|
+
# Hint: everything before `yield` is __enter__; everything after is __exit__.
|
|
14
|
+
|
|
15
|
+
from contextlib import contextmanager
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@contextmanager
|
|
19
|
+
def managed_counter():
|
|
20
|
+
# Bug: body is missing — add counter, yield, then cleanup.
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
with managed_counter() as counter:
|
|
25
|
+
counter.append(1)
|
|
26
|
+
counter.append(2)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Exercise: Context Managers 7
|
|
2
|
+
# I AM NOT DONE
|
|
3
|
+
#
|
|
4
|
+
# `__exit__` can suppress exceptions by returning True. Complete
|
|
5
|
+
# `SilentZeroDivision` so that any ZeroDivisionError raised inside
|
|
6
|
+
# the with-block is silently swallowed (execution continues after
|
|
7
|
+
# the with-block as if no exception occurred).
|
|
8
|
+
#
|
|
9
|
+
# * If `exc_type` is `ZeroDivisionError`, return True (suppress it).
|
|
10
|
+
# * For every other exception (or no exception), return None (propagate).
|
|
11
|
+
#
|
|
12
|
+
# Hint: `if exc_type is ZeroDivisionError: return True`
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SilentZeroDivision:
|
|
16
|
+
def __enter__(self):
|
|
17
|
+
return self
|
|
18
|
+
|
|
19
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
20
|
+
# Bug: always returns None, so ZeroDivisionError is not suppressed.
|
|
21
|
+
return None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
result = "not set"
|
|
25
|
+
with SilentZeroDivision():
|
|
26
|
+
result = 1 / 0 # should be suppressed
|
|
27
|
+
result = "unreachable"
|
|
28
|
+
|
|
29
|
+
# If suppression works, `result` stays "not set" because the exception
|
|
30
|
+
# aborts the rest of the block body before the second assignment.
|