--ini-enunciat >>> from porra import premis >>> premis('exemple1.txt', (1,2)) (6, ['Joan C.', 'Marta'], 1.5, ['Joan P.'], 2.0, 1.0) >>> premis('exemple1.txt', (2,1)) (6, ['Lola'], 3.0, [], 0.0, 3.0) >>> premis('exemple1.txt', (4,4)) (6, [], 0.0, ['Ignasi'], 2.0, 4.0) --fi-enunciat >>> lnoms1 = ["Pat", "Pep", "Jan", "Rut", "Pol", "Kim", "Max", "Cai"] >>> lres1 = [(0,0), (1,2), (0,0), (3,0), (2,1), (3,0), (2,0), (0,0)] >>> with open("/tmp/apostes1.txt", "w") as f: ... for nom, res in zip(lnoms1, lres1): ... a = f.write("{}: {}-{}\n".format(nom, res[0], res[1])) >>> premis('/tmp/apostes1.txt', (3,0)) (8, ['Kim', 'Rut'], 2.0, [], 0.0, 4.0) >>> premis('/tmp/apostes1.txt', (2,0)) (8, ['Max'], 4.0, [], 0.0, 4.0) >>> premis('/tmp/apostes1.txt', (2,0)) (8, ['Max'], 4.0, [], 0.0, 4.0) >>> lnoms2 = ["Pat", "Mei", "Ana", "Pep", "Jan", "Rut", "Pol", "Kim", "Max", "Cai", "Ana"] >>> lres2 = [(0,0), (1,1), (0,1), (1,1), (0,1), (0,1), (0,0), (0,0), (1,0), (2,0), (3,1)] >>> with open("/tmp/apostes2.txt", "w") as f: ... for nom, res in zip(lnoms2, lres2): ... a = f.write("{}: {}-{}\n".format(nom, res[0], res[1])) >>> a, b, c, d, e, f = premis('/tmp/apostes2.txt', (2,0)) >>> print(a, b ,c, d, f"{e:.2f}", f"{f:.2f}") 11 ['Cai'] 5.5 ['Ana'] 3.67 1.83 >>> premis('/tmp/apostes2.txt', (1,0)) (11, ['Max'], 5.5, [], 0.0, 5.5) >>> premis('/tmp/apostes2.txt', (8,2)) (11, [], 0.0, [], 0.0, 11.0) >>> import os >>> os.remove("/tmp/apostes1.txt") >>> os.remove("/tmp/apostes2.txt")