TelenkovDmitry преди 5 месеца
родител
ревизия
75605ef8ed
променени са 2 файла, в които са добавени 53 реда и са изтрити 2 реда
  1. 50 0
      courses/python_func/func_args.py
  2. 3 2
      courses/python_func/func_return.py

+ 50 - 0
courses/python_func/func_args.py

@@ -0,0 +1,50 @@
+
+def words_length(data: list):
+    return [len(x) for x in data]
+
+
+def filter_long_words(data: list, n: int):
+    return [x for x in data if len(x) > n]
+
+
+def is_member(value, lst: list):
+    return value in lst
+
+
+# Пересечение множеств
+def overlapping(l1: list, l2: list):
+    return bool(set(l1).intersection(l2))
+
+
+def find_longest_word_len(lst: list):
+    return max([len(x) for x in lst])
+
+
+def register_check(dct: dict):
+    return len([x for x in dct.values() if x == 'yes'])
+
+
+# Объединение списков в список кортежей
+def create_tuples(l1: list, l2: list):
+    return list(zip(l1, l2))
+
+
+def make_header(text: str, level: int):
+    return f'<h{level}>{text}</h{level}>'
+
+
+def main():
+    # print(words_length(['Python', 'is', 'awesome!'])) 
+    # print(filter_long_words(['Python', 'stole', 'my', 'heart'], 4))
+    # print(overlapping(['this', 'might', 'work'], ['or', 'maybe', 'this']))
+    # print(find_longest_word_len(['default', 'ghostwriter', 'bother', 'applaud', 'skate', 'way']))
+
+    # people = {'Igor': 'yes', 'Stas': 'no', 'Peter': 'no', 'Mary': 'yes'}
+    # print(register_check(people))
+
+    # print(create_tuples([1, 2, 3, 4], [5, 6, 7, 8]))
+
+    print(make_header('Нет', 1))
+
+if __name__ == '__main__':
+    main()

+ 3 - 2
courses/python_func/func_1.py → courses/python_func/func_return.py

@@ -119,6 +119,8 @@ def is_dunder(st):
     len(st) >= 6 and st[2:-2].isalpha()
 
 
+
+
 def main():
     # print_histogram([1, 2, 3])
     # print(test_1('hello'))
@@ -128,8 +130,7 @@ def main():
     # print(count_leap_years(2021, 2021))
     # print(get_leap_years(1990, 2021))
     # print(is_strings_equal('afdsa', 'aasdfa'))
-    
-
+    pass
 
 
 if __name__ == '__main__':