Opakovanie: Ako sa zapise ntica zlozena z 1 polozky? Aky je rozdiel medzi mnozinou a zoznamom? Ake operacie mozeme robit so slovnikom? Z coho sa sklada slovnik? Naco je dobry? Ako ulozit pre kluc, hodnotu? Triedenie - sorted(): Klasicke hodnoty, strinky,... sorted([1,4,2]) --> [1,2,4] sorted([1,4,2], reverse = True) --> [4,2,1] Ntice,listy - najprv podla 1. zlozky, 2. ... sorted([(3,), (1,'a'), (0,'c'), (0,'b')]) --> [(0,b),(0,c),(1,'a'),(3,)] Ntice podla 2. polozky - urcime co je kluc (to podla coho sa triedi): sorted(l, key = lambda x: x[1]) Ntice podla 2. polozky a 1. polozky : sorted(l, key = lambda x: x[1], x[0]) 0. Mnozina a Slovniky - spustite si 8.3 a 8.4. https://docs.python.org/3/tutorial/datastructures.html https://docs.python.org/2/library/sets.html https://docs.python.org/2/library/stdtypes.html#mapping-types-dict Vytvorenie: list = [1,2,3] set = {1,2,3} dict = {"Fero":1, "Jozo":2, "Karol":3} Comprehension: list = [x for x in something] set = {x for x in something} dict = {x:x*x for x in something} Prechod: dic = {"a":1, "b":2} for i in something: # something = list, set, dict (kluce!) print(i) for key in dic.keys(): # to iste ako for key in dict print(key) for key,value in dic.items(): print(key, value) https://www.fi.muni.cz/IB111/sbirka/08-datove_struktury.html 1. Sbirka 8.4.1 unique_check(temp) za pouzitia mnozin: (DU !!! tu len diskusia) Ako by to vyzeralo bez pouzitia mnozin? Co je efektivnejsie? 2. Pomocou mnozin nahodne usporiadajte zoznam. (DU !!! tu len diskusia) suffle([1,2,3,4]) --> [3,1,4,2] 3. Vygenerujte nahodny zoznam k prvkov z intervalu kde kazda hodnota bude prave raz. rand_sample(k, a = 0, b = 10) 4. Sbirka 8.3.1 Morzeovka: encode(text), decode(text) 5. Sbirka 8.3.2 freq_analysis(text): - vypise pocet jednotlivych pismen utriedeny vzostupne.