3/1: tupla = ("aspirina", 2) 3/2: x, y = tupla 3/3: x 3/4: y 3/5: runfile('C:/Users/Studente/Desktop/prova_for.py', wdir='C:/Users/Studente/Desktop') 3/6: runfile('C:/Users/Studente/Desktop/prova_for.py', wdir='C:/Users/Studente/Desktop') 3/7: runfile('C:/Users/Studente/Desktop/prova_for.py', wdir='C:/Users/Studente/Desktop') 3/8: runfile('C:/Users/Studente/Desktop/prova_for.py', wdir='C:/Users/Studente/Desktop') 3/9: runfile('C:/Users/Studente/Desktop/prova_for.py', wdir='C:/Users/Studente/Desktop') 3/10: runfile('C:/Users/Studente/Desktop/prova_for.py', wdir='C:/Users/Studente/Desktop') 3/11: 28/3 + 2*30/3 3/12: 28/3 + 2*31/3 3/13: l = [0,0,6,2,0,0,0,9,7,10,0,0] 3/14: l.sort() 3/15: l 3/16: dizionario = {1:1, 4.5:1} 3/17: dizionario = {1:1, 4.5:1, 'a':1, (1,2):1} 3/18: dizionario = {1:1, 4.5:1, 'a':1, (1,2):'a', 3:[1,2,3], 4:[[2,3],2], 6:3.1, 7:(1,2)} 3/19: dizionario 3/20: 1 in dizionario 3/21: dizionario[1] 3/22: dizionario] 3/23: dizionario['a'] 3/24: dizionario[4.5] 3/25: dizionario.get('a') 3/26: dizionario[0] 3/27: dizionario.get(0) 3/28: dizionario[0] 3/29: dizionario.get(0) 3/30: dizionario.get(0) 3/31: t = 3/32: t = dizionario.get(0) 3/33: t 3/34: t = dizionario.get(0, 0) 3/35: t 3/36: t = dizionario.get(0, 1000) 3/37: t 3/38: for k in dizionario: print(k) 3/39: for k in dizionario: if type(k)==int: print(k) 3/40: for k in dizionario: if type(k)==int: print(dizionario[k]) 3/41: for k in dizionario: if type(k)==int: print(k, dizionario[k]) 3/42: for k in dizionario: print(k, dizionario[k]) 3/43: dizionario 3/44: dizionario[1] 3/45: dizionario[1]+=1 3/46: dizionario[1] 3/47: dizionario[(1,2)] 3/48: dizionario[(1,2)] += 'bc' 3/49: dizionario[(1,2)] 3/50: dizionario[(1,2)] = 'bc' 3/51: dizionario[(1,2)] 3/52: d = {} 3/53: d = dict() 3/54: d[5]=5 3/55: d 3/56: 6 in d == False 3/57: d.get(5) 3/58: d[5]=10 3/59: d.get(5) 3/60: d.get(6) 3/61: d.get(6, 0) 3/62: def dizionario_conta5(lista): dizionario ={} for valore in lista: if dizionario.get(valore) == True: # print(valore, 'TROVATO') dizionario[valore] +=1 else: # print(valore, 'NON TROVATO') dizionario[valore] =1 return dizionario 3/63: l 3/64: dizionario_conta5(l) 3/65: l[0] 3/66: l[0] == True 3/67: def dizionario_conta5(lista): dizionario ={} for valore in lista: if valore in dizionario == True: # print(valore, 'TROVATO') dizionario[valore] +=1 else: # print(valore, 'NON TROVATO') dizionario[valore] =1 return dizionario 3/68: dizionario_conta5(l) 3/69: l 3/70: dizionario_conta5(l) 3/71: l 3/72: def dizionario_conta5(lista): dizionario ={} for valore in lista: if valore in dizionario == True: # print(valore, 'TROVATO') dizionario[valore] +=1 else: # print(valore, 'NON TROVATO') dizionario[valore] =1 return dizionario 3/73: l 3/74: dizionario_conta5(l) 3/75: def dizionario_conta5(lista): dizionario ={} for valore in lista: if valore in dizionario: # print(valore, 'TROVATO') dizionario[valore] +=1 else: # print(valore, 'NON TROVATO') dizionario[valore] =1 return dizionario 3/76: dizionario_conta5(l) 3/77: 6 in d == True 3/78: 5 in d == True 3/79: 5 3/80: 5 in d 3/81: 5 in (d == True) 3/82: (5 in d) == True 3/83: 5 in d == True 3/84: 5 in (d == True) 3/85: (5 in d) == True 3/86: 5 in (d == True) 3/87: 5 in (d == True,) 3/88: def lista_senza_ripetizioni(lista): l = [] for elemento in lista: if elemento not in l: l.append(elemento) return l 3/89: l 3/90: lista_senza_ripetizioni(l) 3/91: set(l) 3/92: s = _ 3/93: ss = {6,7,12} 3/94: s.intersection(ss) 3/95: s.union(ss) 3/96: s 3/97: ss 3/98: s.difference(ss) 3/99: 7 in 3/100: 7 ins 3/101: 7 in s 3/102: s[4] 3/103: l 3/104: runfile('C:/Users/Studente/Desktop/dizionario_conta.py', wdir='C:/Users/Studente/Desktop') 3/105: l 3/106: %timeit dizionario_conta(l) 3/107: %timeit dizionario_conta1(l) 3/108: %timeit dizionario_conta2(l) 3/109: %timeit dizionario_conta3(l) 3/110: %timeit dizionario_conta5(l) 3/111: runfile('C:/Users/Studente/Desktop/dizionario_conta.py', wdir='C:/Users/Studente/Desktop') 3/112: %timeit dizionario_conta5(l) 3/113: runfile('C:/Users/Studente/Desktop/dizionario_conta.py', wdir='C:/Users/Studente/Desktop') 3/114: %timeit dizionario_conta5(l) 3/115: %timeit dizionario_conta6(l) 3/116: import random 3/117: l2 = [1]*543722 + [2] * (1000000-543722) 3/118: len(l2) 3/119: %timeit dizionario_conta(l2) 3/120: %timeit dizionario_conta(l2) 3/121: l2 = [1]*54372 + [2] * (100000-54372) 3/122: %timeit dizionario_conta(l2) 3/123: %timeit dizionario_conta2(l2) 3/124: %timeit dizionario_conta1(l2) 3/125: %timeit dizionario_conta3(l2) 3/126: %timeit dizionario_conta5(l2) 3/127: %timeit dizionario_conta6(l2) 3/128: l3 = [random.randint(-1000,1000) for _ in range(10000)] 3/129: %timeit dizionario_conta1(l3) 3/130: %timeit dizionario_conta2(l3) 3/131: %timeit dizionario_conta3(l3) 3/132: %timeit dizionario_conta5(l3) 3/133: %timeit dizionario_conta6(l3) 3/134: runfile('C:/ProgramData/Anaconda3/Lib/site-packages/IPython/core/magics/ripetizioni_finali.py', wdir='C:/ProgramData/Anaconda3/Lib/site-packages/IPython/core/magics') 3/135: runfile('C:/ProgramData/Anaconda3/Lib/site-packages/IPython/core/magics/ripetizioni_finali.py', wdir='C:/ProgramData/Anaconda3/Lib/site-packages/IPython/core/magics') 3/136: ripetizioni_finali("In quest'anno ho preso per me nessun regalo!") 3/137: ripetizioni_finali2("In quest'anno ho preso per me nessun regalo!") 3/138: ripetizioni_finali2("Ciao come stai?") 3/139: ord('⏩') 3/140: ord('⤵') 3/141: a = 'abc' 3/142: for c in a: print(c) 3/143: b = 'zxc' 3/144: for i in range(len(a)): print(a[i], b[i]) 4/1: d = {'apple':2, 'pear':5, 'banana':3, 'peach':3} 4/2: d 4/3: d['apple'] 4/4: d[5] = 12 4/5: d 4/6: d.keys() 4/7: d.values() 4/8: d2 = {} 4/9: d2 = dict() 4/10: d2['a'] = 12 4/11: runfile('C:/Users/Studente/Desktop/unit2/count_numbers.py', wdir='C:/Users/Studente/Desktop/unit2') 4/12: count_numbers(l) 4/13: runfile('C:/Users/Studente/Desktop/unit2/count_numbers.py', wdir='C:/Users/Studente/Desktop/unit2') 4/14: count_numbers(l) 4/15: runfile('C:/Users/Studente/Desktop/unit2/count_numbers.py', wdir='C:/Users/Studente/Desktop/unit2') 4/16: count_numbers2(l) 4/17: import random 4/18: big_list = random.choices(range(-1000,1000), 10000) 4/19: big_list = random.choice(range(-1000,1000), 10000) 4/20: big_list = random.choice(range(-1000,1000), k=10000) 4/21: big_list = random.choices(range(-1000,1000), k=10000) 4/22: len(big_list) 4/23: %timeit count_numbers(big_list) 4/24: %timeit count_numbers2(big_list) 4/25: runfile('C:/Users/Studente/Desktop/unit2/count_numbers.py', wdir='C:/Users/Studente/Desktop/unit2') 4/26: %timeit count_numbers(big_list) 4/27: %timeit count_numbers2(big_list) 4/28: d 4/29: d['blueberry'] = [1,2,3] 4/30: d 4/31: d['blueberry'].append(5) 4/32: runfile('C:/Users/Studente/Desktop/unit2/repetitions.py', wdir='C:/Users/Studente/Desktop/unit2') 4/33: repetitions('hello world') 4/34: d = repetitions('hello world') 4/35: for key in d: print(key, d[key]) 4/36: d.keys() 4/37: d.values() 4/38: d.items() 4/39: for key, value in repetitions('this is a very long sentence!!').items(): print(key, value) 4/40: a,b = (5,6) 4/41: a 4/42: b 4/43: a,b,c=(5,6,7) 4/44: a 4/45: b 4/46: c 4/47: for key in d: print(key, d[key]) 4/48: for key in d.values(): print(key, d[key]) 4/49: d.key() 4/50: d.keys() 4/51: d.values() 4/52: d 4/53: l 4/54: d1 4/55: type(d.values()) 4/56: runfile('C:/Users/Studente/Desktop/unit2/most_frequent_final.py', wdir='C:/Users/Studente/Desktop/unit2') 4/57: most_frequent_final(['apple', 'pear','banana', 'peach', 'pineapple']) 4/58: a 4/59: b 4/60: l 4/61: l = ['apple', 'pear','banana', 'peach', 'pineapple'] 4/62: l 4/63: sorted(l) 4/64: sorted(l, key=len) 4/65: max(l, key=len) 4/66: min(l, key=len) 4/67: def criteria(string): return len(string), string[0] 4/68: sorted(l, key=criteria) 4/69: def criteria(string): return string[-1] 4/70: sorted(l, key=criteria) 4/71: max(l, key=criteria) 4/72: min(l, key=criteria) 4/73: for el in l: print(criteria(el)) 4/74: d 4/75: d.keys() 4/76: max(d.keys(), key=d.get) 4/77: d.values('h') 4/78: d.values() 4/79: max(d, key=d.get) 4/80: def criteria(string): return string[-1] 4/81: l 4/82: sorted(l, key = lambda x: x[-1]) 4/83: sorted(l, key = lambda x: x[1]) 4/84: sorted(l, key = lambda x: (len, x[0],)) 4/85: sorted(l, key = lambda x: (len(x), x[0],)) 4/86: sorted(l, key = lambda x: (len, x[0])) 4/87: len 4/88: runfile('C:/Users/Studente/Desktop/unit2/most_frequent_final.py', wdir='C:/Users/Studente/Desktop/unit2') 4/89: runfile('C:/Users/Studente/Desktop/unit2/most_frequent_final.py', wdir='C:/Users/Studente/Desktop/unit2') 4/90: most_frequent_final(['apple', 'pear','banana', 'peach', 'pineapple']) 4/91: runfile('C:/Users/Studente/Desktop/unit2/most_frequent_final.py', wdir='C:/Users/Studente/Desktop/unit2') 4/92: most_frequent_final(['apple', 'pear','banana', 'peach', 'pineapple']) 5/1: ord('☠') 5/2: '☠' - '☺' 5/3: '☠'.isalnum() 5/4: diz = {'mela':5, 'pera':2, 'caco':3, 'castagna':7, 'banana':7, 'mirtillo':4} 5/5: diz['noce di cocco'] = 10 5/6: diz[2] 5/7: d 5/8: dz 5/9: diz 5/10: diz['mela'] 5/11: diz[2] = 6 5/12: diz[2.2] = 6 5/13: diz[True] = 6 5/14: diz[('mela','banana')] = 6 5/15: diz[[1,2,3]] = 6 5/16: help(dict) 5/17: diz.pop(2.2) 5/18: diz.popitem(2) 5/19: diz.pop(2) 5/20: 'mela' in diz 5/21: diz.get('mela') 5/22: diz['mela'] 5/23: diz.get('mela') 5/24: diz.get('melo') 5/25: diz['melo'] 5/26: diz.get('melo') 5/27: diz.get('melo',10) 5/28: diz 5/29: 5 in diz 5/30: diz2={'mela':-1} 5/31: diz2.update(diz) 5/32: diz2['mela'] 5/33: diz.get('melo') 5/34: diz.get('melo',10) 5/35: runfile('C:/Users/Studente/Desktop/conta_lettere.py', wdir='C:/Users/Studente/Desktop') 5/36: runfile('C:/Users/Studente/Desktop/conta_lettere.py', wdir='C:/Users/Studente/Desktop') 5/37: 11111111111aaaaaaaaaaaaaa" 5/38: conta("11111111111aaaaaaaaaaaaaa") 5/39: runfile('C:/Users/Studente/Desktop/conta_lettere.py', wdir='C:/Users/Studente/Desktop') 5/40: conta("11111111111aaaaaaaaaaaaaa") 5/41: conta2("11111111111aaaaaaaaaaaaaa") 5/42: diz 5/43: diz.keys() 5/44: diz.values() 5/45: diz.items() 5/46: for k in diz: print(k) 5/47: for k in diz.keys(): print(k) 5/48: for k in diz.values(): print(k) 5/49: for k in diz.items(): print(k) 5/50: for k, val in diz.items(): print(k, val) 5/51: a,b,c = 5,6,7 5/52: a 5/53: b 5/54: c 5/55: a,b,c = [5,6,7] 5/56: a 5/57: b 5/58: for k, val in enumerate(diz): print(k, val) 5/59: diz[0] 5/60: runfile('C:/Users/Studente/Desktop/conta_seconde.py', wdir='C:/Users/Studente/Desktop') 5/61: trova_max_seconda(['mela', 'pera', 'caco', 'castagna', 'banana', 'mirtillo', 'noce di cocco']) 5/62: l = ['mela', 'pera', 'caco', 'castagna', 'banana', 'mirtillo', 'noce di cocco'] 5/63: runfile('C:/Users/Studente/Desktop/conta_seconde.py', wdir='C:/Users/Studente/Desktop') 5/64: trova_max_seconda2(l) 5/65: runfile('C:/Users/Studente/Desktop/conta_seconde.py', wdir='C:/Users/Studente/Desktop') 5/66: trova_max_seconda2(l) 5/67: l 5/68: sorted(l) 5/69: sorted(l, key = len) 5/70: def criterio(stringa): return stringa[1] 5/71: sorted(l, key = criterio) 5/72: sorted(l, key = lambda s: s[1]) 5/73: def criterio(stringa): return len(stringa), stringa[1], stringa[0] 5/74: sorted(l, key = criterio) 5/75: def criterio(stringa): return len(stringa), stringa[-1] 5/76: sorted(l, key = criterio) 5/77: max(l, key = criterio) 5/78: runfile('C:/Users/Studente/Desktop/conta_seconde.py', wdir='C:/Users/Studente/Desktop') 5/79: trova_max_seconda3(l) 5/80: runfile('C:/Users/Studente/Desktop/lista_da_diz.py', wdir='C:/Users/Studente/Desktop') 5/81: runfile('C:/Users/Studente/Desktop/lista_da_diz.py', wdir='C:/Users/Studente/Desktop') 5/82: lista_da_diz({'a':3, 'b':6, 'albero':1, 5:4}) 5/83: runfile('C:/Users/Studente/Desktop/lista_da_diz.py', wdir='C:/Users/Studente/Desktop') 5/84: lista_da_diz({'a':3, 'b':6, 'albero':1, 5:4}) 5/85: {'a':[1,2,3]} 5/86: o = {'a':[1,2,3]} 5/87: o['a'] 5/88: len(o['a']) 5/89: o['a'].append(7) 5/90: o['a'] 5/91: runfile('C:/Users/Studente/Desktop/liste_parole_finali.py', wdir='C:/Users/Studente/Desktop') 5/92: liste_parole_finali("Nel mezzo del cammin di nostra vita") 5/93: runfile('C:/Users/Studente/Desktop/liste_parole_finali.py', wdir='C:/Users/Studente/Desktop') 5/94: liste_parole_finali("Nel mezzo del cammin di nostra vita") 5/95: liste_parole_finali("Nel mezzo del cammin di nostra vita aaaaaa") 5/96: runfile('C:/Users/Studente/Desktop/liste_parole_finali.py', wdir='C:/Users/Studente/Desktop') 5/97: liste_parole_finali("Nel mezzo del cammin di nostra vita aaaaaa") 5/98: runfile('C:/Users/Studente/Desktop/liste_parole_finali.py', wdir='C:/Users/Studente/Desktop') 5/99: liste_parole_finali("Nel mezzo del cammin di nostra vita aaaaaa") 5/100: runfile('C:/Users/Studente/Desktop/liste_parole_finali.py', wdir='C:/Users/Studente/Desktop') 5/101: liste_parole_finali("Nel mezzo del cammin di nostra vita aaaaaa") 5/102: %history 5/103: %history -f "20211027M-Z-hist.py" 3/145: %history -f "20211027A-L-hist.py" 4/93: %history -f "20211027U2-hist.py" 6/1: dir(str) 6/2: 'pappa'.translate({ord('p'):ord('c')}) 6/3: 'pappa'.translate({ord('p'):''}) 6/4: 'pappa'.translate({ord('p'):ord('c'), ord('a'):ord('o')}) 6/5: 'pappa'.replace('p','c') 6/6: 'pappa'.replace('p','c').replace('a','o') 6/7: dir(str) 6/8: d = {'a':1, 'b':45, 'c':10,'d':0} 6/9: d 6/10: sorted(d) 6/11: d 6/12: d = {'a':1, 'b':45, 'c':10,'d':0, 'z':100, 'q':2} 6/13: d 6/14: sorted(d) 6/15: d 6/16: sorted(d, key = d.get) 6/17: sorted(d, key = d.get, reversed=True) 6/18: sorted(d, key = d.get, reverse=True) 6/19: sorted(d, key = lambda k: d[k]) 6/20: sorted(d, key = lambda k: -d[k]) 6/21: sorted(d, key = -d.get) 6/22: sorted(d, key = lambda k: (-d[k], k)) 6/23: d['e']=2 6/24: d 6/25: sorted(d, key = lambda k: (-d[k], k)) 6/26: l1 = [1,2,3,4,5] 6/27: l2 = ['a','b','c','d','e','f'] 6/28: for i in zip(l1,l2): print(i) 6/29: %timeit 6/30: f = open('C:\Users\Studente\Desktop\conta_lettere.py') 6/31: f = open('C:/Users/Studente/Desktop/conta_lettere.py') 6/32: f 6/33: g = open('Desktop/conta_lettere.py') 6/34: f 6/35: g 6/36: f.read() 6/37: g.readline() 6/38: g.readlines() 6/39: f.close() 6/40: g.close() 6/41: f = open('Downloads/testo.txt') 6/42: f 6/43: f.read() 6/44: f.read() 6/45: f 6/46: f.seek(0) 6/47: f 6/48: f.read() 6/49: f.seek(4) 6/50: f.read() 6/51: help(f) 6/52: f.seek(0) 6/53: for line in f.readlines(): print(line) 6/54: f.seek(0) 6/55: for line in f.readlines(): print(line, end='') 6/56: f.seek(0) 6/57: for line in f.readlines(): print(line.strip()) 6/58: f.seek(0) 6/59: for line in f.readlines(): print(line[:-1]) 6/60: f.seek(0) 6/61: for line in f: print(line) 6/62: f.close() 6/63: with open('Downoads/testo.txt') as f: f.read() 6/64: with open('Downloads/testo.txt') as f: f.read() 6/65: f.seek(0) 6/66: with open('Downloads/testo.txt') as f: s = f.read() 6/67: s 6/68: f.seek(0) 6/69: ord('a') 6/70: with open('Downloads/testo.txt', 'rb') as f: s = f.read() 6/71: s 6/72: f = open('Downloads/testo.txt', 'rb') 6/73: f 6/74: g = open('Downloads/testo.txt', 'rt') 6/75: f 6/76: t 6/77: f 6/78: q 6/79: f 6/80: g 6/81: g = open('Desktop/Desktop.zip', 'rt') 6/82: g 6/83: s = g.read() 6/84: s 6/85: g = open('Desktop/Desktop.zip', 'rb') 6/86: s = g.read() 6/87: s 6/88: a = \x05 6/89: a = 0x5 6/90: a 6/91: a = 0x15 6/92: a 6/93: a = b'\x05' 6/94: a 6/95: g = open('Downloads/testo.txt', 'rt') 6/96: g.write('miciomiao') 6/97: g.close() 6/98: g = open('Downloads/testo.txt', 'w') 6/99: g.write('miciomiao') 6/100: g.flush() 6/101: g 6/102: g.write('baubau') 6/103: g.flush() 6/104: g.write('à') 6/105: g.write('え') 6/106: l 6/107: l1 6/108: l2 6/109: g.writelines(l2) 6/110: g.flush() 6/111: for el in l2: print(el, file=g) 6/112: g.flush() 6/113: g.close() 6/114: g = open('Downloads/testo.txt', 'a') 6/115: g = open('testo.txt', 'a') 6/116: for el in l2: print(el, file=g) 6/117: g.flush() 6/118: g.seek(20) 6/119: for el in l2: print(el, file=g) 6/120: g.flush() 6/121: g.seek(0) 6/122: for el in l2: print(el, file=g) 6/123: g.seek(0) 6/124: g.flush() 6/125: g.close() 6/126: g = open('testo.txt', 'a') 6/127: g.writelines(l2) 6/128: g.close() 6/129: diz = {x:0 for x in 'aeiou'} 6/130: diz 6/131: 'casa'[-1] 6/132: 'casa'[-1] in diz 6/133: runfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/134: print(conta_finali('Downloads/6personaggi.txt')) 6/135: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/136: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/137: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/138: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/139: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/140: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/141: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/142: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/143: debugfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/144: "it,".isalpha() 6/145: "it,"[-1].isalpha() 6/146: "it,"[:-1].isalpha() 6/147: runfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/148: runfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/149: runfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/150: runfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/151: print(conta_finali('Downloads/6personaggi.txt')) 6/152: runfile('C:/Users/Studente/conta_finali.py', wdir='C:/Users/Studente') 6/153: print(conta_finali('Downloads/6personaggi.txt')) 6/154: 'città'.isalpha() 6/155: 'città'[-1] in diz 6/156: runfile('C:/Users/Studente/salva_ripetizioni.py', wdir='C:/Users/Studente') 6/157: salva_ripetizioni([1,1,1,7,7,3,3,3.4,3.4,3.5,'casa','a','a',1], 'ripe.txt') 6/158: runfile('C:/Users/Studente/salva_ripetizioni.py', wdir='C:/Users/Studente') 6/159: salva_ripetizioni([1,1,1,7,7,3,3,3.4,3.4,3.5,'casa','a','a',1], 'ripe.txt') 6/160: runfile('C:/Users/Studente/salva_ripetizioni.py', wdir='C:/Users/Studente') 6/161: salva_ripetizioni([1,1,1,7,7,3,3,3.4,3.4,3.5,'casa','a','a',1], 'ripe.txt') 7/1: l1 = [234, 123, 678] 7/2: l2 = [5, 4, 9] 7/3: zip(l1, l2) 7/4: for i in zip(l1, l2): print(i) 7/5: def build_dict(key_list, value_list): return {i:j for i,j in zip(key_list, value_list)} 7/6: build_dict(l1, l2) 7/7: dict(l1,l2) 7/8: dict(zip(l1,l2)) 7/9: runfile('C:/Users/Studente/vowels_list.py', wdir='C:/Users/Studente') 7/10: vowels_list('apple,pineapple,coconut,pear,peach,mango,chestnut') 7/11: fh = open('myfile.txt', 'w') 7/12: fh.write('Hello world!") 7/13: fh.write('Hello world!') 7/14: fh.close() 7/15: fh = open('myfile.txt', 'w') 7/16: fh.write('Hello world!') 7/17: fh.flush() 7/18: fh.write('Hello world!') 7/19: fh.write('Hello mummy!') 7/20: fh.write('Hello daddy!') 7/21: fh.write('Hello bros!') 7/22: fh.flush() 7/23: fh.write(' Hello bros!') 7/24: fh.flush() 7/25: fh.writelines(['a','b','c','d']) 7/26: fh.flush() 7/27: print('Hello world!', file = fh) 7/28: fh.flush() 7/29: for i in ['a','b','c','d']: print(i, file=fh) 7/30: fh.flush() 7/31: fh.close() 7/32: fh = open('myfile.txt', 'r') 7/33: fh.read() 7/34: fh2 = open('HW2-req/a.txt') 7/35: fh2.readline() 7/36: fh2.readline() 7/37: fh2.readline() 7/38: fh2.readline() 7/39: fh2.readline() 7/40: fh2.readline() 7/41: fh2.readline() 7/42: fh2.readline() 7/43: fh2.readline() 7/44: fh2.readline() 7/45: fh2.seek(0) 7/46: fh2.readline() 7/47: fh2.readline() 7/48: fh2.readline() 7/49: fh2.readline() 7/50: fh2.readline() 7/51: fh2.readline() 7/52: fh2.seek(40) 7/53: fh2.readline() 7/54: fh2.readline() 7/55: fh2.seek(40) 7/56: fh2.seek(0) 7/57: fh2.readlines() 7/58: fh2.close() 7/59: fh2 = open('HW2-req/a.txt') 7/60: for line in fh.readlines(): print(line) 7/61: for line in fh2.readlines(): print(line) 7/62: for line in fh2.readlines(): print(line[:-1]) 7/63: fh2.seek(0) 7/64: for line in fh2.readlines(): print(line[:-1]) 7/65: fh2.seek(0) 7/66: for line in fh2.readlines(): print(line, end='') 7/67: for line in fh2.readlines(): print(line.rstrip()) 7/68: fh2.seek(0) 7/69: for line in fh2.readlines(): print(line.rstrip()) 7/70: fh2 = open('HW2-req/a.txt') # READING MODE 7/71: fh2 = open('HW2-req/a.txt', 'w') # WRITING MODE 7/72: runfile('C:/Users/Studente/Downloads/HW2-req/file_freq.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/73: runfile('C:/Users/Studente/Downloads/HW2-req/file_freq.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/74: file_freq=('a.txt') 7/75: runfile('C:/Users/Studente/Downloads/HW2-req/file_freq.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/76: file_freq('a.txt') 7/77: runfile('C:/Users/Studente/Downloads/HW2-req/write_list_repetitions.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/78: write_list_repetitions(['A','A','A','v','v','A',3,(1,2)], 'myfile.txt') 7/79: A =['a',123,'b'] 7/80: B= [5, 'b', 123] 7/81: for i in zip(A,B): print(i) 7/82: help(dict) 7/83: dict(zip(A,B)) 7/84: runfile('C:/Users/Studente/ordina_parole_complex.py', wdir='C:/Users/Studente') 7/85: for i in ['cane','topo','gatto','cavallo','giraffa','ippopotamo','rinoceronte']: print(criteri(i)) 7/86: for i in 'topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(criteri(i)) 7/87: for i in 'topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(len(i)) 7/88: 'cavallo'.count('aeiou') 7/89: 'cavallo'.count('aeiou') 7/90: runfile('C:/Users/Studente/ordina_parole_complex.py', wdir='C:/Users/Studente') 7/91: ordina_parole_complex('topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo') 7/92: ordina_parole_complex('topo,zioo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo') 7/93: for i in 'topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(lambda x: (sum([x.count(v) for v in 'aeiou']), len(x), x))) 7/94: def f (s): return (sum([x.count(v) for v in 'aeiou']), len(x), x) 7/95: for i in 'topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(s(i)) 7/96: for i in 'topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(f(i)) 7/97: def f (x): return (sum([x.count(v) for v in 'aeiou']), len(x), x) 7/98: for i in 'topo,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(f(i)) 7/99: for i in 'topo,ziio,cavallo,cane,gatto,rinoceronte,giraffa,ippopotamo'.split(','): print(f(i)) 7/100: a = 0x3041 7/101: a 7/102: a = 0x1F58D 7/103: a 7/104: 2**16 7/105: 2**24 7/106: 0x7f 7/107: 0x800 7/108: 0xffff 7/109: file 7/110: file 7/111: id 7/112: file 7/113: file = open('Downloads/testuale.txt','w') 7/114: file.write('Buona sera a tutti!') 7/115: file.flush() 7/116: file.write('Benvenuti alla nostra esercitazione') 7/117: file.write('Vi stavamo aspettando') 7/118: file.flush() 7/119: for i in range(1,11): print(i, file=file) 7/120: file.flush() 7/121: file.close() 7/122: file.write('Vi stavamo aspettando') 7/123: for i in range(1,11): print(i, file=file) 7/124: l = ['pippo','pluto','paperino'] 7/125: f = open('Downloads/testuale.txt') 7/126: f.write('Ciao') 7/127: f.close() 7/128: f = open('Downloads/testuale.txt', 'w') 7/129: f.writelines(l) 7/130: f.close() 7/131: f = open('Downloads/testuale.txt', 'a') 7/132: f.write('minnie') 7/133: f.close() 7/134: f = open('Downloads/testuale.txt') 7/135: f.read() 7/136: f.read() 7/137: f.seek(0) 7/138: f.read() 7/139: f.seek(0) 7/140: f.read() 7/141: f.seek(0) 7/142: f.read() 7/143: f.seek(5) 7/144: f.read() 7/145: f.seek(10) 7/146: f.read() 7/147: f.seek(0) 7/148: f.read(5) 7/149: f.read(5) 7/150: f.read(5) 7/151: f.read(5) 7/152: f.read(5) 7/153: f.seek(0) 7/154: f.close() 7/155: with open('Downloads/testuale.txt') as f: f.read() 7/156: f.seek() 7/157: f.seek(0) 7/158: with open('Downloads/testuale.txt') as f: f.read() f.seek(0) f.read() 7/159: f = open('Downloads/HW2-req/a.txt') 7/160: f.read() 7/161: f.seek(0) 7/162: f.readline() 7/163: f.readline() 7/164: f.readline() 7/165: f.readline() 7/166: f.readline() 7/167: f.readline() 7/168: f.seek(0) 7/169: for line in f: print(line) 7/170: f.seek(0)for line in f: print(line) 7/171: f.seek(0) 7/172: return 4 7/173: f.seek(0)for line in f: print(line[:-1]) 7/174: for line in f: print(line[:-1]) 7/175: f.seek(0) 7/176: for line in f: print(line, end = '') 7/177: f.seek(0) 7/178: for line in f: print(line.strip()) 7/179: f.seek(0) 7/180: f.readlines() 7/181: f.close() 7/182: f = open('Downloads/HW2-req/b.txt') 7/183: f.read() 7/184: f.close() 7/185: f = open('Downloads/HW2-req/b.txt', encoding='UTF-8') 7/186: f.read() 7/187: f.seek(0) 7/188: f.read(2) 7/189: f.seek(1) 7/190: f.read(2) 7/191: f.close() 7/192: f = open('Downloads/26.zip', encoding='UTF-8') 7/193: f.read() 7/194: f.close() 7/195: f = open('Downloads/26.zip', 'b', encoding='UTF-8') 7/196: f = open('Downloads/26.zip', 'b') 7/197: f = open('Downloads/26.zip', 'rb') 7/198: f.read() 7/199: f 7/200: g = open('Downloads/26.zip', encoding='UTF-8') 7/201: g 7/202: f.close() 7/203: g.close() 7/204: '\U123' 7/205: '\U1230' 7/206: '\U0123' 7/207: '\U0F' 7/208: dict('aeiou',0) 7/209: dict.fromkeys('aeiou',0) 7/210: return d 7/211: runfile('C:/Users/Studente/ordina_parole_complex.py', wdir='C:/Users/Studente') 7/212: runfile('C:/Users/Studente/Downloads/HW2-req/conta_parole_vocali.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/213: conta_parole_vocali('../6personaggi.txt') 7/214: debugfile('C:/Users/Studente/Downloads/HW2-req/conta_parole_vocali.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/215: runfile('C:/Users/Studente/Downloads/HW2-req/conta_parole_vocali.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/216: runfile('C:/Users/Studente/Downloads/HW2-req/conta_parole_vocali.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/217: runfile('C:/Users/Studente/Downloads/HW2-req/conta_parole_vocali.py', wdir='C:/Users/Studente/Downloads/HW2-req') 7/218: runfile('C:/Users/Studente/Downloads/HW2-req/conta_parole_vocali.py', wdir='C:/Users/Studente/Downloads/HW2-req') 9/1: %history -g -f 3nov.txt 10/1: with open('testo.txt') as f: riga = f.readline() 10/2: riga2 = f.readline() 10/3: f = open('testo.txt') riga = f.readline() 10/4: riga2 = f.readline() 10/5: with open('testo.txt') as f: riga = f.readline() riga2 = f.readline() 10/6: riga3 = f.readline() 10/7: f 10/8: f.close() 10/9: f = open('testo.txt') 10/10: f.readline() 10/11: f.readline() 10/12: f.readline() 10/13: f.readline() 10/14: f.readline() 10/15: f.readline() 10/16: f.readline() 10/17: f.readline() 10/18: f.seek(0) 10/19: f.readline() 10/20: f.seek(10) 10/21: f.readline() 10/22: f.seek(0) 10/23: f.read() 10/24: f.seek(0) 10/25: f.readlines() 10/26: f.seek(20) 10/27: f.readlines() 10/28: f.seek(120) 10/29: f.readlines() 10/30: f 10/31: f.seek(0) 10/32: testo = f.read() 10/33: testo.index('é') 10/34: testo 10/35: testo.index('perch') 10/36: testo.index(ord('é')) 10/37: testo.index(chr(ord('é'))) 10/38: f.close() 10/39: f = open('testo.txt', encoding = 'utf-8') 10/40: testo = f.read() 10/41: f 10/42: r 10/43: testo 10/44: testo.index(ord('é')) 10/45: testo.index('é') 10/46: f.seek(95) 10/47: f.read(1) 10/48: f.seek(95) 10/49: f.seek(96) 10/50: f.read(1) 10/51: f.read(1) 10/52: f = open('b.txt') 10/53: f 10/54: f.read(1) 10/55: f.close() 10/56: f = open('b.txt', encoding = 'utf8') 10/57: f.read(1) 10/58: f.seek(1) 10/59: f.read(1) 10/60: f.read(1) 10/61: f.read(1) 10/62: f.seek(0) 10/63: f.read(1) 10/64: f.seek(2) 10/65: f.read(1) 10/66: f.seek(3) 10/67: f.read(1) 10/68: f.read(1) 10/69: f.read(1) 10/70: f.read(1) 10/71: f.close() 10/72: f = open('scrivo.txt', 'w') 10/73: f 10/74: f.close() 10/75: f = open('scrivo.txt', 'w', encoding='utf8') 10/76: f.write('Questa è una bellissima giornata') 10/77: f.flush() 10/78: f.seek(0) 10/79: f.write('Questa è una bella giornata') 10/80: f.flush() 10/81: f.writelines(['a','e','i',' ','o','u']) 10/82: f.flush() 10/83: f.writelines(['a','e','i',' ','o','u']) 10/84: f.close() 10/85: f.writelines(['a','e','i',' ','o','u']) 10/86: f = open('scrivo.txt', 'w', encoding='utf8') 10/87: f.close() 10/88: f = open('scrivo.txt', 'w', encoding='utf8') 10/89: f.writelines(['a','e','i',' ','o','u']) 10/90: f.close() 10/91: f = open('scrivo.txt', 'w+', encoding='utf8') 10/92: f.close() 10/93: f = open('scrivo.txt', 'a', encoding='utf8') 10/94: f.writelines(['a','e','i',' ','o','u']) 10/95: f.close() 10/96: f = open('scrivo.txt', 'a', encoding='utf8') 10/97: f.close() 10/98: f = open('scrivo.txt', 'a', encoding='utf8') 10/99: f.seek(0) 10/100: f.write('eee') 10/101: f.close() 10/102: f = open('scrivo.txt', 'w', encoding='utf8') 10/103: f.write('eee') 10/104: f.seek(0) 10/105: f.read() 10/106: f.close() 10/107: f = open('scrivo.txt', 'w+', encoding='utf8') 10/108: f.write('eee') 10/109: f.seek(0) 10/110: f.read() 10/111: help(open) 10/112: f.close() 10/113: f = open('scrivo.txt', 'a+', encoding='utf8') 10/114: f.seek(0) 10/115: f.write('OOO') 10/116: f.close() 10/117: f = open('scrivo.txt', 'w', encoding='utf8') 10/118: f.write('OOO') 10/119: f.seek(0) 10/120: f.read() 10/121: f.close() 10/122: f = open('scrivo.txt', 'w+', encoding='utf8') 10/123: f.write('OOO') 10/124: f.seek(0) 10/125: f.read() 10/126: f.close() 10/127: f = open('scrivo.txt', 'a', encoding='utf8') 10/128: f.seek(0) 10/129: f.read() 10/130: f.close() 10/131: f = open('scrivo.txt', 'a+', encoding='utf8') 10/132: f.seek(0) 10/133: f.read() 10/134: f.close() 10/135: dir(str) 10/136: runfile('C:/Users/Studente/trasforma.py', wdir='C:/Users/Studente') 10/137: trasforma('trasforma.py','trasformato.txt') 10/138: isalpa() 10/139: runfile('C:/Users/Studente/riccardo.py', wdir='C:/Users/Studente') 10/140: [[],[],[],[]] 10/141: [[1,2,3],[3,4,5],[2,3,4],[1,2,3]] 10/142: matrice = [[1,2,3],[3,4,5],[2,3,4],[1,2,3]] 10/143: matrice[0] 10/144: matrice[0][1] 10/145: 2**8*2**8*2**8 10/146: black = (0,0,0) 10/147: white = (255,255,255) 10/148: import images 10/149: img = [] 10/150: for riga in range(50): riga_nera = [black] * 100 10/151: for riga in range(50): riga_nera = [black] * 100 img.append(riga_nera) 10/152: img 10/153: img[0] 10/154: len(img[0]) 10/155: len(img) 10/156: images.ipd(img) 10/157: images.visd(img) 10/158: images.save(img, 'primaimmagine.png') 10/159: red = (255,0,0) 10/160: img [25] = [red] * 100 10/161: images.save(img, 'primaimmagine.png') 10/162: img [len(img)] = [red] * 100 10/163: img [len(img)-1] = [red] * 100 10/164: images.save(img, 'primaimmagine.png') 10/165: img [-1] = [red] * 100 10/166: img [-1] = [(123,15,87)] * 100 10/167: images.save(img, 'primaimmagine.png') 10/168: img [-1] = [(123,155,187)] * 100 10/169: images.save(img, 'primaimmagine.png') 10/170: for riga in range(50): riga_bianca = [white] * 100 img.append(riga_nera) 10/171: images.save(img, 'primaimmagine.png') 10/172: white 10/173: for riga in range(50): riga_bianca = [white] * 100 img.append(riga_bianca ) 10/174: images.save(img, 'primaimmagine.png') 10/175: img [-1] = [(123,15,87)] * 100 10/176: images.save(img, 'primaimmagine.png') 10/177: for i, riga in enumerate(img): img[i][5] = (0,156,230) 10/178: images.save(img, 'primaimmagine.png') 10/179: new_im = [] 10/180: for riga in len(100): new_im.append([white]*100) 10/181: for riga in range(100): new_im.append([white]*100) 10/182: images.visd(new_im) 10/183: new_im[50] = [black] * 100 10/184: images.visd(new_im) 10/185: new_im = [[black] * 100] * 100 10/186: images.save(new_im, 'newim.png') 10/187: new_im[50] = [white] * 100 10/188: images.save(new_im, 'newim.png') 10/189: new_im[56][0] = [white] 10/190: new_im[56][0] = white 10/191: images.save(new_im, 'newim.png') 10/192: new_im[56][6] = white 10/193: images.save(new_im, 'newim.png') 10/194: new_im = [[black] * 100 for _ in range (100)] 10/195: new_im[56][6] = white 10/196: images.save(new_im, 'newim.png') 10/197: new_im [56] = [black] * 99 10/198: images.save(new_im, 'newim.png') 10/199: new_im [56] = [black] * 9 10/200: images.save(new_im, 'newim.png') 10/201: new_im [56] = [black] 10/202: images.save(new_im, 'newim.png') 10/203: images.visd(new_im) 10/204: [1,2,3,4][0:2] = [9,9,9] 10/205: l=[1,2,3,4] 10/206: l[0:2] = [9,9,9] 10/207: l 10/208: runfile('C:/Users/Studente/riccardo.py', wdir='C:/Users/Studente') 11/1: runfile('C:/Users/Studente/crea_cornice.py', wdir='C:/Users/Studente') 11/2: runfile('C:/Users/Studente/crea_cornice.py', wdir='C:/Users/Studente') 11/3: runfile('C:/Users/Studente/crea_cornice.py', wdir='C:/Users/Studente') 11/4: runfile('C:/Users/Studente/Downloads/crea_cornice.py', wdir='C:/Users/Studente/Downloads') 11/5: runfile('C:/Users/Studente/Downloads/crea_cornice.py', wdir='C:/Users/Studente/Downloads') 11/6: i = crea_cornice(500,500) 11/7: images.save(i, 'cornice.png') 11/8: runfile('C:/Users/Studente/Downloads/crea_cornice.py', wdir='C:/Users/Studente/Downloads') 11/9: i = crea_cornice(500,500) 11/10: images.save(i, 'cornice.png') 12/1: (1,5) > (1,7) 12/2: (1,5) > (2,7) 12/3: (1,5) > (0,7) 12/4: map(mykey, [1,2,3,4,5,6]) 12/5: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/6: map(mykey, [1,2,3,4,5,6]) 12/7: list(_) 12/8: sort(_) 12/9: sorted(_) 12/10: sorted([1,2,3,4,5,6], key=mykey) 12/11: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/12: sorted([1,2,3,4,5,6], key=mykey) 12/13: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/14: sorted([1,2,3,4,5,6], key=mykey) 12/15: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/16: sorted([1,2,3,4,5,6], key=mykey) 12/17: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/18: sorted([1,2,3,4,5,6], key=mykey) 12/19: sorted([1,2,3,4,5,6], key=lambda i:-(i%2 - 1)/i) 12/20: sorted([1,2,3,4,5,6], key=lambda i: (0,i) if i%2 else (1,-i)) 12/21: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/22: sorted([1,2,3,4,5,6], key=mykey) 12/23: list(map(mykey, [1,2,3,4,5,6])) 12/24: runfile('C:/Users/Studente/sorting_key.py', wdir='C:/Users/Studente') 12/25: list(map(mykey, [1,2,3,4,5,6])) 12/26: runfile('C:/Users/Studente/from_file_to_list.py', wdir='C:/Users/Studente') 12/27: from_file_to_int_list('ripe.txt') 12/28: ord('.') 12/29: list(map(ord,'asdasd')) 12/30: sum(map(ord,'asdasd')) 12/31: runfile('C:/Users/Studente/from_file_to_list.py', wdir='C:/Users/Studente') 12/32: from_file_to_int_list('ripe.txt') 12/33: runfile('C:/Users/Studente/remove_identical.py', wdir='C:/Users/Studente') 12/34: def remove_identical(mylist): for i in range(len(mylist)-1): if mylist[i] == mylist[i+1]: del mylist[i+1] l = [1,1,1,2,3,'a','a','a',1] 12/35: l = [1,1,1,2,3,'a','a','a',1] 12/36: remove_identical(l) 12/37: list.find 12/38: list.remove 12/39: def remove_identical(mylist): for i,el in enumerate(mylist[:-1]): if el == mylist[i+1]: mylist.remove(el) l = [1,1,1,2,3,'a','a','a',1] 12/40: remove_identical(l) 12/41: def remove_duplicate(mylist): for el in mylist: if mylist.count(el) > 1: mylist.remove(el) l = [1,1,1,2,3,'a','a','a',1] 12/42: remove_duplicate(l) 12/43: l 12/44: def remove_identical(mylist): i = 0 while i < len(mylist)-1: if mylist[i] == mylist[i+1]: del mylist[i+1] else: i += 1 12/45: l = [1,1,1,2,3,'a','a','a',1] 12/46: remove_identical(l) 12/47: l 12/48: def remove_identical(mylist): for i in range(len(mylist)-1,0,-1): if mylist[i] == mylist[i-1]: del mylist[i] 12/49: def remove_identical(mylist): for i in range(len(mylist)-1,0,-1): if mylist[i] == mylist[i-1]: del mylist[i] 12/50: l = [1,1,1,2,3,'a','a','a',1] 12/51: remove_identical(l) 12/52: l 12/53: def remove_identical(mylist): deleted = 0 for i in range(len(mylist)-1): if mylist[i-deleted] == mylist[i-deleted+1]: del mylist[i-deleted+1] deleted += 1 12/54: l = [1,1,1,2,3,'a','a','a',1] 12/55: remove_identical(l) 12/56: l 12/57: help(list) 12/58: def remove_identical_rec(mylist): if len(mylist) <= 1: return if mylist[0] == mylist[1]: mylist.pop(0) remove_identical_rec(mylist[1:]) 12/59: l = [1,1,1,2,3,'a','a','a',1] 12/60: remove_identical_rec(l) 12/61: l 12/62: debugfile('C:/Users/Studente/remove_identical.py', wdir='C:/Users/Studente') 12/63: def remove_identical_rec(mylist, i=0): if i == len(mylist)- 1: return if mylist[i] == mylist[i+1]: mylist.pop(i) else: i+=1 remove_identical_rec(mylist, i) 12/64: l = [1,1,1,2,3,'a','a','a',1] 12/65: remove_identical(l) 12/66: l 12/67: l = [1,1,1,2,3,'a','a','a',1] 12/68: remove_identical_rec(l) 12/69: l 12/70: def remove_identical_rec(mylist, i=0): if i == len(mylist)- 1: return if mylist[i] == mylist[i+1]: del mylist[i] else: i+=1 remove_identical_rec(mylist, i) 12/71: l = [1,1,1,2,3,'a','a','a',1] 12/72: remove_identical_rec(l) 12/73: l 12/74: d = {chr(i):0 for i in range(ord('a'),ord('z')+1)} 12/75: d 12/76: debugfile('C:/Users/Studente/remove_identical.py', wdir='C:/Users/Studente') 12/77: runfile('C:/Users/Studente/remove_identical.py', wdir='C:/Users/Studente') 12/78: relative_frequency.py({},'alice.txt') 12/79: runfile('C:/Users/Studente/relative_frequency.py', wdir='C:/Users/Studente') 12/80: relative_frequency.py({},'alice.txt') 12/81: relative_frequency({},'alice.txt') 12/82: relative_frequency({},'alice.txt') 12/83: runfile('C:/Users/Studente/relative_frequency.py', wdir='C:/Users/Studente') 12/84: relative_frequency({},'alice.txt') 12/85: relative_frequency({},'alice.txt') 12/86: d = {chr(i):text.count(chr(i)) for i in range(ord('a'),ord('z')+1)} 12/87: d = {chr(i):0 for i in range(ord('a'),ord('z')+1)} 12/88: relative_frequency(d,'alice.txt') 12/89: d = {chr(i):{} for i in range(ord('a'),ord('z')+1)} 12/90: relative_frequency(d,'alice.txt') 12/91: d 12/92: relative_frequency(d,'promessi.txt') 12/93: d 14/1: map(len,['asd','wewqewqe','ewew']) 14/2: list(_) 14/3: map(lambda x: len(x)%2,['asd','wewqewqe','ewew']) 14/4: filter(lambda x: len(x)%2,['asd','wewqewqe','ewew']) 14/5: list(_) 14/6: map(lambda x: len(x)%2,['asd','wewqewqe','ewew']) 14/7: _.next() 14/8: m = map(lambda x: len(x)%2,['asd','wewqewqe','ewew']) 14/9: m.__next__() 14/10: m.__next__() 14/11: m.__next__() 14/12: m.__next__() 14/13: help(map) 14/14: m = map(lambda x: len(x)%2,['asd','wewqewqe','ewew']) 14/15: next(m) 14/16: next(m) 14/17: next(m) 14/18: next(m) 14/19: filter(lambda x: len(x)%2,['asd','wewqewqe','ewew']) 14/20: next(_) 14/21: next(_) 14/22: True == 5%2 14/23: 5%2 14/24: if 5%2: print(True) 14/25: runfile('C:/Users/Studente/relative_frequency.py', wdir='C:/Users/Studente') 14/26: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/27: sorted([1,1,1,2,333,3,4,21,3], key=my_key_function) 14/28: sorted([1,1,6,1,2,333,3,4,21,3], key=my_key_function) 14/29: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/30: sorted([1,1,6,1,2,333,3,4,21,3], key=my_key_function) 14/31: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/32: sorted([1,1,6,1,2,333,3,4,21,3], key=my_key_function) 14/33: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/34: sorted([1,1,6,1,2,333,3,4,21,3], key=my_key_function) 14/35: sorted([1,2,3,4,5,6], key=my_key_function) 14/36: sorted([1,2,3,6,5,4], key=my_key_function) 14/37: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/38: sorted([1,2,3,6,5,4], key=my_key_function) 14/39: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/40: sorted([1,2,3,6,5,4], key=my_key_function) 14/41: l = [1,2,3,4,5,6] 14/42: for c in zip(l,map(my_key_function,l)): print(c) 14/43: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/44: for c in zip(l,map(my_key_function,l)): print(c) 14/45: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/46: sorted([1,2,3,6,5,4], key=my_key_function) 14/47: runfile('C:/Users/Studente/sorting_integers_odd_even.py', wdir='C:/Users/Studente') 14/48: sorted([1,2,3,6,5,4], key=my_key_function) 14/49: runfile('C:/Users/Studente/elimina_consecutivi.py', wdir='C:/Users/Studente') 14/50: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/51: elimina_consecutivi(l) 14/52: runfile('C:/Users/Studente/elimina_consecutivi.py', wdir='C:/Users/Studente') 14/53: elimina_consecutivi(l) 14/54: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/55: elimina_consecutivi(l) 14/56: runfile('C:/Users/Studente/elimina_consecutivi.py', wdir='C:/Users/Studente') 14/57: elimina_consecutivi(l) 14/58: def elimina_consecutivi(lista): i = 0 while i < len(lista) -1: if lista[i] == lista[i+1]: lista.pop(i) else: i+=1 14/59: l = [1,2,3,4,5,6] 14/60: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/61: elimina_consecutivi(l) 14/62: l 14/63: def elimina_consecutivi(lista): for i in range(len(lista)-1, 0, -1): if lista[i] == lista[i-1]: lista.pop(i) 14/64: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/65: elimina_consecutivi(l) 14/66: l 14/67: def elimina_identici(lista): for el in lista: if lista.count(el) > 1: lista.remove(el) 14/68: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/69: elimina_identici(l) 14/70: l 14/71: runfile('C:/Users/Studente/elimina_consecutivi.py', wdir='C:/Users/Studente') 14/72: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/73: elimina_identici(l) 14/74: l 14/75: def elimina_consecutivi(lista): contatore = 0 for i in range(len(lista)-1): if lista[i-contatore] == lista[i-contatore+1]: lista.pop(i-contatore) contatore += 1 14/76: l= [1,1,1,2,3,4,'a','a','a',1,5,5] 14/77: elimina_consecutivi(l) 14/78: l 14/79: with open('myfile.txt','w') as file_aperto: print('Abbelliiii','de zio', file=file_aperto) 14/80: runfile('C:/Users/Studente/gestione_file.py', wdir='C:/Users/Studente') 14/81: def file_lunghezze(filein, fileout): contatore = 0 with open (filein) as file_aperto_l: with open(fileout, 'w') as file_aperto_s: for riga in file_aperto_l: lunghezze = map(len, riga.split()) file_aperto_s.writelines(" ".join(map(str, lunghezze))) file_aperto_s.write('\n') contatore += len(lunghezze) return contatore 14/82: file_lunghezze('testo.txt','testo_lunghezze.txt') 14/83: def file_lunghezze(filein, fileout): contatore = 0 with open (filein) as file_aperto_l: with open(fileout, 'w') as file_aperto_s: for riga in file_aperto_l: lunghezze = map(len, riga.split()) file_aperto_s.writelines(" ".join(map(str, lunghezze))) file_aperto_s.write('\n') contatore += len(riga.split()) return contatore 14/84: file_lunghezze('testo.txt','testo_lunghezze.txt') 1: %history -g -f "10nov.txt"