This repository has been 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
firsf task #5
Open
iminlan
wants to merge
8
commits into
ItPeoplePython2018:master
Choose a base branch
from
iminlan:patch-1
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
firsf task #5
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4ef7160
Update tests.py
iminlan b09262b
Update tests.py
iminlan 5da8780
Update tests.py
iminlan cc7285e
Update tests.py
iminlan 09e37ab
Update tests.py
iminlan 677ea78
Update tests.py
iminlan e5c89e8
Update tests.py
iminlan 6c5366d
Update tests.py
iminlan 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,11 +1,17 @@ | ||
import math | ||
|
||
def test_even_fucntion(): | ||
""" | ||
Необходимо реализовать функцию even_filter, которая получает неограниченное количество аргументов | ||
и возвращает из них только четные. | ||
""" | ||
|
||
def even_filter(*args): | ||
pass | ||
res = [] | ||
for count in args: | ||
if args[count-1]%2==0: | ||
res.append(args[count-1]) | ||
return res | ||
|
||
assert even_filter(1, 2, 3, 4, 5, 6) == [2, 4, 6] | ||
|
||
|
@@ -16,7 +22,9 @@ def test_increment_decorator(): | |
декрорируемую функцию. | ||
""" | ||
def increment_derocator(func): | ||
pass | ||
def decor(val): | ||
return func(val)+1 | ||
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.
|
||
return decor | ||
|
||
@increment_derocator | ||
def returner(value): | ||
|
@@ -25,27 +33,27 @@ def returner(value): | |
assert returner(1) == 2 | ||
|
||
|
||
|
||
def test_point_segment_class(): | ||
""" | ||
Дано: есть класс Point, описывающий точку на плоскости. Необходимо закончить класс Segment, описывающий отрезок, | ||
принимающий на вход 2 точки и позволяющий посчитать его длину. | ||
Модуль с математическими функциями называется math, документация по нему находится здесь: | ||
https://docs.python.org/3/library/math.html?highlight=math#module-math | ||
""" | ||
|
||
""" | ||
class Point(): | ||
def __init__(self, x, y): | ||
self.x = x | ||
self.y = y | ||
|
||
|
||
|
||
class Segment(): | ||
def __init__(self, p1, p2): | ||
pass | ||
|
||
self.p1 = p1 | ||
self.p2 = p2 | ||
|
||
def length(self): | ||
return 0 | ||
|
||
sq1 = (self.p1.x - self.p2.x)**2 | ||
sq2 = (self.p1.y - self.p2.y)**2 | ||
return math.sqrt(sq1 + sq2) | ||
|
||
p1 = Point(0, 0) | ||
p2 = Point(3, 4) | ||
assert Segment(p1, p2).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.
Итератор будет идти не по индексам списка, а по значениям. Т.е. тут не
for count in args
, аfor arg in args
.Если там окажутся не idx + 1, как в тесте, а
[1, 9, 3, 4, 5, 2, 10]
, то код сломается.