forked from dualboot-partners/eu-python-learn-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f67621
commit 09617a3
Showing
11 changed files
with
104 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
version: "3.7" | ||
services: | ||
python: | ||
python-course: | ||
build: . | ||
volumes: | ||
- .:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
from exercises.filter_map import FilterMapExercise | ||
|
||
|
||
def is_not_null_even(x: int) -> tuple[bool, int]: | ||
if not x or x % 2: | ||
return False, 0 | ||
return True, x | ||
|
||
|
||
def square_positive(x: int) -> tuple[bool, int]: | ||
if x >= 0: | ||
return True, x * x | ||
return False, 0 | ||
|
||
|
||
class TestFilterMapExercise: | ||
def test_filter_map(self) -> None: | ||
def is_odd(x: int) -> tuple[bool, int]: | ||
if not x or x % 2: | ||
return False, 0 | ||
return True, x | ||
|
||
empty = FilterMapExercise.filter_map(is_odd, []) | ||
assert not empty | ||
assert isinstance(empty, list) | ||
empty = FilterMapExercise.filter_map(is_not_null_even, []) | ||
assert empty == [] | ||
|
||
filtered_list = FilterMapExercise.filter_map(is_odd, [-1, 0, 1, 2, 4]) | ||
filtered_list = FilterMapExercise.filter_map(is_not_null_even, [-1, 0, 1, 2, 4]) | ||
assert filtered_list == [2, 4] | ||
|
||
filtered_list = FilterMapExercise.filter_map(is_not_null_even, [-1, 0, 1, 2, 4]) | ||
assert filtered_list == [0, 0, 1, 4, 16] |
Oops, something went wrong.