|
@@ -40,6 +40,55 @@ def find_keys(**kwargs):
|
|
|
return sorted(lst, key=str.lower)
|
|
|
|
|
|
|
|
|
+
|
|
|
+def get_extensions(file_list):
|
|
|
+ def _get_extansions(file_name):
|
|
|
+ if "." in file_name:
|
|
|
+ ext = file_name.split(".")[-1]
|
|
|
+ else:
|
|
|
+ ext = ""
|
|
|
+ return ext
|
|
|
+
|
|
|
+ return [_get_extansions(i) for i in file_list]
|
|
|
+
|
|
|
+
|
|
|
+def double_odd_numbers(numbers):
|
|
|
+
|
|
|
+ def double(value):
|
|
|
+ return 2*value
|
|
|
+
|
|
|
+ def is_odd(value):
|
|
|
+ return value%2 != 0
|
|
|
+
|
|
|
+ return [double(num) for num in numbers if is_odd(num)]
|
|
|
+
|
|
|
+
|
|
|
+def calculate(x, y, operation='a'):
|
|
|
+ def addition(x, y):
|
|
|
+ print(x + y)
|
|
|
+ def subtraction(x, y):
|
|
|
+ print(x - y)
|
|
|
+ def division(x, y):
|
|
|
+ if y == 0:
|
|
|
+ print("На ноль делить нельзя!")
|
|
|
+ else:
|
|
|
+ print(x/y)
|
|
|
+ def multiplication(x, y):
|
|
|
+ print(x*y)
|
|
|
+
|
|
|
+ if operation == 'a':
|
|
|
+ addition(x, y)
|
|
|
+ elif operation == 's':
|
|
|
+ subtraction(x, y)
|
|
|
+ elif operation == 'd':
|
|
|
+ division(x, y)
|
|
|
+ elif operation == 'm':
|
|
|
+ multiplication(x, y)
|
|
|
+ else:
|
|
|
+ print('Ошибка. Данной операции не существует')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
def main():
|
|
|
|
|
|
|
|
@@ -55,7 +104,17 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
- print(find_keys(At=[4], awaited=(3,), aDobe=[5]))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ calculate(2, 5)
|
|
|
+ calculate(2.2, 15, 'a')
|
|
|
+ calculate(22, 15, 's')
|
|
|
+ calculate(2, 3.2, 'm')
|
|
|
+ calculate(10, 0.4, 'd')
|
|
|
|
|
|
|
|
|
|