From f30cafd359fe486e2ef5e47dd6fc6990af7f105f Mon Sep 17 00:00:00 2001 From: Hixje Date: Wed, 16 Nov 2022 13:37:53 +0300 Subject: [PATCH 1/5] add lab.py --- python/src/lab.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 python/src/lab.py diff --git a/python/src/lab.py b/python/src/lab.py new file mode 100644 index 0000000..a142090 --- /dev/null +++ b/python/src/lab.py @@ -0,0 +1,23 @@ +from numpy import arange + +# задача A + + +def y(x): + y = ((((x - a) ** 2) ** (1.0 / 3)) + (abs(x + b) ** (1.0 / 5))) / ((x ** 2 - (a + b) ** 2) ** (1.0 / 9)) + return y + + +for x in arange(1.23, 7.23, 1.2): + a = 0.8 + b = 0.4 + print(y(x)) + +# задача B +xrange = [1.88, 2.26, 3.84, 4.55, -6.21] +xlen = len(xrange) +for i in range(0, xlen): + x = xrange[i] + a = 0.8 + b = 0.4 + print(y(x)) From e2f3f2945873fed6ed65c78b34785c459d17332c Mon Sep 17 00:00:00 2001 From: Hixje Date: Wed, 16 Nov 2022 13:49:00 +0300 Subject: [PATCH 2/5] add lab.py --- python/src/lab.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/src/lab.py b/python/src/lab.py index a142090..d037ce1 100644 --- a/python/src/lab.py +++ b/python/src/lab.py @@ -1,4 +1,3 @@ -from numpy import arange # задача A @@ -8,10 +7,12 @@ def y(x): return y -for x in arange(1.23, 7.23, 1.2): +x = 1.23 +while x < 7.23: a = 0.8 b = 0.4 print(y(x)) + x += 1.2 # задача B xrange = [1.88, 2.26, 3.84, 4.55, -6.21] From c42ee889ac391f8bb40826436fac986dcc915bab Mon Sep 17 00:00:00 2001 From: Hixje Date: Wed, 30 Nov 2022 14:14:09 +0300 Subject: [PATCH 3/5] changed lab.py --- python/src/lab.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/python/src/lab.py b/python/src/lab.py index d037ce1..deb0171 100644 --- a/python/src/lab.py +++ b/python/src/lab.py @@ -3,22 +3,21 @@ def y(x): + a = 0.8 + b = 0.4 y = ((((x - a) ** 2) ** (1.0 / 3)) + (abs(x + b) ** (1.0 / 5))) / ((x ** 2 - (a + b) ** 2) ** (1.0 / 9)) return y x = 1.23 while x < 7.23: - a = 0.8 - b = 0.4 print(y(x)) x += 1.2 + # задача B xrange = [1.88, 2.26, 3.84, 4.55, -6.21] xlen = len(xrange) for i in range(0, xlen): x = xrange[i] - a = 0.8 - b = 0.4 - print(y(x)) + print(y(x)) \ No newline at end of file From 6a89ddaab51f4793bae5969b3a3a3c6470f5e5e0 Mon Sep 17 00:00:00 2001 From: Hixje Date: Wed, 30 Nov 2022 14:15:14 +0300 Subject: [PATCH 4/5] changed lab.py --- python/src/lab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/lab.py b/python/src/lab.py index deb0171..0577b1c 100644 --- a/python/src/lab.py +++ b/python/src/lab.py @@ -20,4 +20,4 @@ def y(x): xlen = len(xrange) for i in range(0, xlen): x = xrange[i] - print(y(x)) \ No newline at end of file + print(y(x)) From 669187e23378ed83481fe3e4a8f162ecf5fdbbf0 Mon Sep 17 00:00:00 2001 From: Hixje Date: Wed, 7 Dec 2022 00:34:42 +0300 Subject: [PATCH 5/5] codewars tasks --- python/codewars.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 python/codewars.py diff --git a/python/codewars.py b/python/codewars.py new file mode 100644 index 0000000..12bf876 --- /dev/null +++ b/python/codewars.py @@ -0,0 +1,53 @@ +# task 1 +def even_or_odd(number): + if number % 2 == 0: + return "Even" + else: + return "Odd" + + +# task 2 +def count_sheeps(sheep): + return sheep.count(True) + + +# task 3 +def monkey_count(n): + result = [] + for num in range(1, n + 1): + result.append(num) + return result + + +# task 4 +def paperwork(n, m): + return n * m if n > 0 and m > 0 else 0 + + +# task 5 +def hero(b, d): + bulletsneeded = d * 2 + if b >= bulletsneeded: + return True + else: + return False + + +# task 1 +def correct_polish_letters(st): + pol = {"ą": "a", "ć": "c", "ę": "e", "ł": "l", "ń": "n", "ó": "o", "ś": "s", "ź": "z", "ż": "z"} + return "".join([pol[i] if i in pol else i for i in st]) + + +# task 2 +def find_all(array, n): + arr = [] + for i in range(len(array)): + if array[i] == n: + arr.append(i) + return arr + + +# task 3 +def sum_of_minimums(numbers): + return sum(map(min, numbers))