aliassaf wrote: > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the relation between the two variables, in the other > hand if I look to the program x=2 y=4, x=3 y=9 ect... it is going to show me > that f (t)!!!
That is not possible at all. There are too many possible functions mapping 2 to 4, 3 to 9 etc. You can, however, create a list of candidate functions and check your input pairs (x,y) against each of those functions to see if any of them matches. Short, unoptimized example: functions = [ lambda x: x, lambda x: x+1, lambda x: x*x, lambda x: x**3, ] input = [(1,1), (2,2)] for function in functions: for x,y in input: if function(x) != y: break else: print "function", function, "matches" Georg -- http://mail.python.org/mailman/listinfo/python-list