import math def dist(P1,P2): dx = P1['x']-P2['x'] dy = P1['y']-P2['y'] return math.sqrt(dx*dx+dy*dy) L = [] s = 'init' while s != 'stop': try: P={} P['x']= float(raw_input("inserisci la x: ")) P['y']= float(raw_input("inserisci la y: ")) if (P['x']*P['y']<0): print 'solo punti nel primo e terzo quadrante, reinserisci' elif P not in L: L.append(P) else: print "il punto e' gia' in lista, cambia punto" print L s = raw_input("inserisci 'stop' per terminare, enter o altro per proseguire:") except: print 'devi inserire numeri, reinserisci' print L maxD = 0 xm=None ym=None for i in L: d = dist(L[0],i) if d > maxD: maxD = d xm = i['x'] ym = i['y'] print xm,ym xd = L[0]['x'] yd = L[0]['y'] xs = L[0]['x'] ys = L[0]['y'] if len(L)>3: for i in L: if (i['x']>xd): xd = i['x'] if (i['x'] 2: sumx = 0 for i in L: sumx+=i['x'] avgx = sumx/len(L) print avgx print L[2]['x'] if L[2]['x'] > avgx: print "il terzo punto e' a destra del centro" else: print "il terzo punto e' a sinistra del centro" for i in L: if (i['x'] == xd) or (i['x'] == xs): L.remove(i) xd = L[0]['x'] yd = L[0]['y'] xs = L[0]['x'] ys = L[0]['y'] for i in L: if (i['x']>xd): xd = i['x'] yd = i['y'] if (i['x']