This repository was archived by the owner on Oct 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Update tests.py #3
Open
uai-ekb
wants to merge
5
commits into
ItPeoplePython2018:master
Choose a base branch
from
uai-ekb:patch-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
import math | ||
|
||
def test_even_fucntion(): | ||
""" | ||
Необходимо реализовать функцию even_filter, которая получает неограниченное количество аргументов | ||
и возвращает из них только четные. | ||
""" | ||
|
||
def even_filter(*args): | ||
pass | ||
|
||
def even_filter(*args): | ||
my_list = [] | ||
for arg in args: | ||
if not isinstance(arg, int): | ||
continue | ||
if arg % 2 == 0: | ||
my_list.append(arg) | ||
return my_list | ||
|
||
assert even_filter(1, 2, 3, 4, 5, 6) == [2, 4, 6] | ||
assert even_filter(8, 1, 2, 3, 4, 5, 6, "qwe", "asd", 8 , 8) == [8, 2, 4, 6, 8, 8] | ||
|
||
|
||
def test_increment_decorator(): | ||
|
@@ -16,7 +26,10 @@ def test_increment_decorator(): | |
декрорируемую функцию. | ||
""" | ||
def increment_derocator(func): | ||
pass | ||
def wrapper(value): | ||
value += 1 | ||
return func(value) | ||
return wrapper | ||
|
||
@increment_derocator | ||
def returner(value): | ||
|
@@ -41,12 +54,14 @@ def __init__(self, x, y): | |
|
||
class Segment(): | ||
def __init__(self, p1, p2): | ||
pass | ||
|
||
self.p1 = p1 | ||
self.p2 = p2 | ||
|
||
def length(self): | ||
return 0 | ||
|
||
return math.sqrt(pow(self.p1.x - self.p2.x , 2) + pow(self.p1.y - self.p2.y , 2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Здесь перед запятой лишний (по гайдам) пробел. И JFYI в питоне есть и функция возведения в степень, и оператор - a ** 2 == pow(a, 2) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. пробел убрал. за оператор ** спасибо, буду использовать в будущем. |
||
p1 = Point(0, 0) | ||
p2 = Point(3, 4) | ||
|
||
assert Segment(p1, p2).length() == 5.0 | ||
assert Segment(p2, p1).length() == 5.0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вкусовщина, но я бы объединил в 1 строку:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
точно! так эффективнее... спс