diff --git a/labs02/task08.py b/labs02/task08.py index e5eef9a..654b867 100644 --- a/labs02/task08.py +++ b/labs02/task08.py @@ -7,7 +7,15 @@ przez 3 lub 5 mniejszych niż n. """ def sum_div35(n): - + + if n == 0: + return 0 + else: + suma=0 + for i in range(n): + if ((i%3) == 0) or ((i%5) == 0): + suma =suma + i + return suma def tests(f): inputs = [[10], [100], [3845]] diff --git a/labs02/task09.py b/labs02/task09.py index 9045054..525733f 100644 --- a/labs02/task09.py +++ b/labs02/task09.py @@ -7,10 +7,18 @@ na podobnie wyglądające cyfry: 'e' na '3', 'l' na '1', 'o' na '0', 't' na '7'. Np. leet('leet') powinno zwrócić '1337'. """ - def leet_speak(text): - pass - + + for i in range(len(text)): + if ((text[i]) == 'e'): + text = text[:i] + '3' + text[i + 1:] + elif ((text[i]) == 'l'): + text = text[:i] + '1' + text[i + 1:] + elif ((text[i]) == 'o'): + text = text[:i] + '0' + text[i + 1:] + elif ((text[i]) == 't'): + text = text[:i] + '7' + text[i + 1:] + return text def tests(f): inputs = [['leet'], ['do not want']] diff --git a/labs02/task10.py b/labs02/task10.py index 58d40d2..2dcfcb1 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -9,8 +9,12 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'. def pokemon_speak(text): - pass + + for i in range(len(text)): + if ((i % 2) == 0): + text = text[:i] + (text[i].upper()) + text[i + 1:] + return text def tests(f): inputs = [['pokemon'], ['do not want'], ['POKEMON']] diff --git a/labs02/task11.py b/labs02/task11.py index 7d36767..4bc74a7 100644 --- a/labs02/task11.py +++ b/labs02/task11.py @@ -9,7 +9,24 @@ Oba napisy będą składać się wyłacznie z małych liter. """ def common_chars(string1, string2): - pass + n= string1 + m= string2 + li = [] + if len(n) >= len(m): + for i in range(len(n)): + for j in range(len(m)): + if n[i] == m[j]: + li.append(n[i]) + + else: + for i in range(len(m)): + for j in range(len(n)): + if m[i] == n[j]: + li.append(m[i]) + li = list(set(li)) + li.remove(' ') + li.sort() + return li def tests(f): diff --git a/labs04/cw5.py b/labs04/cw5.py new file mode 100644 index 0000000..42d3b2d --- /dev/null +++ b/labs04/cw5.py @@ -0,0 +1,17 @@ +import glob + +sciezka = "/scores/model.iter*.npz.bleu" + +for file in glob.glob(sciezka): + with open(file, 'r') as plik: + for line in plik.readlines(): + bleu = float(line[line.find("=")+ 1:line.find(",")]) + if bleu >0: + max = bleu + maxi = file + + plik.close() + +print ( maxi ) + +