""" Domaci ukol 06 Homework 06 """ import math def distance(a, b): """ 2 bod # 2 point Funkce distance spocita Euklidovskou vzdalenost pro 2 body v n-rozmernem prostoru definovane pomoci listu a, b. Otestujte, jestli jsou vstupni parametry stejne dlouhe. Pokud nejsou vyvolejte vyjimku ValueError() distace = sqrt((a1-b1)**2+(a2-b2)**2+...+(an-bn)**2) >>> distance([1,2,3],[2,4,5]) 3.0 >>> distance([12.6, 20.6, 3.3, 4.6], [2.8, 4.5, 5.9, 10.8]) 20.011246837716037 >>> distance([1,2,3],[2,3]) Traceback (most recent call last): ... ValueError """ # odmocina = math.sqrt() # volani vyjimky raise pass def try_parse(string): """ 3 body # 3 points Funkce try_parse prevedene zadany text na cislo a bude ignorovat neciselne znaky na konci vstupniho parametru. BONUS: >>> try_parse("2.5a") 2.5 >>> try_parse("123hp7") 123.0 >>> try_parse("5@") 5.0 >>> try_parse("6.3e-9") 6.3e-09 >>> try_parse("") 0.0 >>> try_parse("abc") 0.0 """ pass def split_list(l, sep): """ 3 body # 3 points Funkce split_list rozdeli vstupni list na jednotlive podlisty na zaklade zadaneho oddelovace. >>> split_list([1, 2, 3, 1, 2, 3], 2) [[1], [3, 1], [3]] >>> split_list(['a', 'b', 'c', 'd', 'f'], 'c') [['a', 'b'], ['d', 'f']] >>> split_list(['abc', 0, 'ghd', 0, 'gws', 0], 0) [['abc'], ['ghd'], ['gws']] >>> split_list([False, "AATGCT", True, True, "GTAACT", False, True], 0) [['AATGCT', True, True, 'GTAACT'], [True]] """ pass import doctest doctest.testmod()