
def get_info_about_object(obj):
    print(dir(obj))
    print(f'Всего у объекта {len(dir(obj))} атрибутов и методов')


def check_exist_attrs(obj, lst):
    'Возвращает словарь со статусом атрибутов из списка лист у obj'
    return {x:hasattr(obj, x) for x in lst}


def create_attrs(obj, lst):
    for data in lst:
        setattr(obj, data[0], data[1])



def my_test_function():
    pass


def print_goods(lst):
    pass


def count_strings(*args):
    str_count = 0
    for value in args:
        if isinstance(value, str):
            str_count += 1
    return str_count


def find_keys(**kwargs):
    lst = []
    for name, value in kwargs.items():
        if isinstance(value, (list, tuple)):
            lst.append(name)
    
    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():

    # get_info_about_object(my_test_function)
    # print(hasattr(my_test_function, '__code__'))

    # print_goods.is_working = False
    # print_goods.status = 'Not ready'

    # print(check_exist_attrs(print_goods, ['is_working', 'status', 'time', 'speed']))

    # create_attrs(print_goods, [('is_working', False), ('days', 10), ('status', 'Not ready')])
    # print(check_exist_attrs(print_goods, ['sort', 'is_working', 'days', 'status', 'upper']))

    # print(count_strings(1, 2, 'hello', True, 't')) 

    # 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



if __name__ == '__main__':
    main()