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)) diff --git a/python/src/lab.py b/python/src/lab.py new file mode 100644 index 0000000..0577b1c --- /dev/null +++ b/python/src/lab.py @@ -0,0 +1,23 @@ + +# задача A + + +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: + 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] + print(y(x))