|
@@ -40,6 +40,55 @@ def find_keys(**kwargs):
|
|
return sorted(lst, key=str.lower)
|
|
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():
|
|
def main():
|
|
|
|
|
|
# get_info_about_object(my_test_function)
|
|
# get_info_about_object(my_test_function)
|
|
@@ -55,7 +104,17 @@ def main():
|
|
|
|
|
|
# print(count_strings(1, 2, 'hello', True, 't'))
|
|
# print(count_strings(1, 2, 'hello', True, 't'))
|
|
|
|
|
|
- print(find_keys(At=[4], awaited=(3,), aDobe=[5]))
|
|
|
|
|
|
+ # print(find_keys(At=[4], awaited=(3,), aDobe=[5]))
|
|
|
|
+
|
|
|
|
+ # print(get_extensions(["foo.txt", "bar.mp4", "python3"]))
|
|
|
|
+
|
|
|
|
+ # print(double_odd_numbers([-43, 91, 932, 9201, 32, 93]))
|
|
|
|
+
|
|
|
|
+ calculate(2, 5) # Печатает 7.0
|
|
|
|
+ calculate(2.2, 15, 'a') # Печатает 17.2
|
|
|
|
+ calculate(22, 15, 's') # Печатает 7.0
|
|
|
|
+ calculate(2, 3.2, 'm') # Печатает 6.4
|
|
|
|
+ calculate(10, 0.4, 'd') # Печатает 25.0
|
|
|
|
|
|
|
|
|
|
|
|
|