From 84b93381524b0338bf9999cb943c742c6563b6a6 Mon Sep 17 00:00:00 2001 From: Lugvlad <38045446+Lugvlad@users.noreply.github.com> Date: Fri, 22 Jun 2018 16:18:25 +0300 Subject: [PATCH 1/3] =?UTF-8?q?Update=20and=20rename=20tests.py=20to=20?= =?UTF-8?q?=E2=84=9622?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests.py => "homework/\342\204\22622" | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) rename homework/tests.py => "homework/\342\204\22622" (92%) diff --git a/homework/tests.py "b/homework/\342\204\22622" similarity index 92% rename from homework/tests.py rename to "homework/\342\204\22622" index 35e1b26..b5acd64 100644 --- a/homework/tests.py +++ "b/homework/\342\204\22622" @@ -5,7 +5,7 @@ def test_even_fucntion(): """ def even_filter(*args): - pass + return[i for i in args if i % 2 == 0] assert even_filter(1, 2, 3, 4, 5, 6) == [2, 4, 6] @@ -16,12 +16,13 @@ def test_increment_decorator(): декрорируемую функцию. """ def increment_derocator(func): - pass - + def wrapper(value): + func(value+1) + return wrapper + @increment_derocator def returner(value): return value - assert returner(1) == 2 @@ -40,12 +41,16 @@ def __init__(self, x, y): class Segment(): - def __init__(self, p1, p2): - pass - - def length(self): - return 0 - + def __init__(self, p1, p2): + pass + self.p1 = p1 + self.p2 = p2 + + def length(self): + + length = math.hypot(self.p1.x - self.p2.x, self.p1.y - self.p2.y) + + return length p1 = Point(0, 0) p2 = Point(3, 4) assert Segment(p1, p2).length() == 5.0 @@ -93,7 +98,7 @@ def test_is_prime(): """ def is_prime(n): - pass + assert is_prime(2) assert is_prime(3) From e9d5c74d1f335f152108b32739ab9bc375bdea4f Mon Sep 17 00:00:00 2001 From: Lugvlad <38045446+Lugvlad@users.noreply.github.com> Date: Fri, 22 Jun 2018 18:11:34 +0300 Subject: [PATCH 2/3] =?UTF-8?q?Update=20=E2=84=9622?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "homework/\342\204\22622" | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git "a/homework/\342\204\22622" "b/homework/\342\204\22622" index b5acd64..fb9ae33 100644 --- "a/homework/\342\204\22622" +++ "b/homework/\342\204\22622" @@ -77,7 +77,14 @@ def test_translate(): Документация по этому методу: https://docs.python.org/3/library/stdtypes.html#str.join """ def translate(fraze, dictionary): - pass + def translate(fraze, dic): + i = fraze.split() + Num = len(i) + Tran=[] + for a in range(Num): + Tran.append(dic[i[a]]) + return Tran + " ".join(Tran) assert translate("hello world", {"hello": "привет", "world": "мир"}) == "привет мир" assert translate("привет мир", {"привет": "hello", "мир": "world"}) == "hello world" From 3a6e8c5e6610cab798e7a6b891a96e5476eba286 Mon Sep 17 00:00:00 2001 From: Lugvlad <38045446+Lugvlad@users.noreply.github.com> Date: Fri, 22 Jun 2018 18:21:02 +0300 Subject: [PATCH 3/3] =?UTF-8?q?Update=20=E2=84=9622?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "homework/\342\204\22622" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/homework/\342\204\22622" "b/homework/\342\204\22622" index fb9ae33..9b4a853 100644 --- "a/homework/\342\204\22622" +++ "b/homework/\342\204\22622" @@ -83,8 +83,8 @@ def test_translate(): Tran=[] for a in range(Num): Tran.append(dic[i[a]]) - return Tran - " ".join(Tran) + Translate = " ".join(Tran) + return Translate assert translate("hello world", {"hello": "привет", "world": "мир"}) == "привет мир" assert translate("привет мир", {"привет": "hello", "мир": "world"}) == "hello world"