Creating a Simple User Interface for a Function

CTSB01 scott.moore270 at gmail.com
Thu Jul 25 12:03:16 EDT 2013


I have the following code that runs perfectly: 

     def psi_j(x, j):
          rtn = []
          for n2 in range(0, len(x) * j - 2):
            n = n2 / j
            r = n2 - n * j
            rtn.append(j * x[n] + r * (x[n + 1] - x[n]))
            print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
          return rtn

This code takes a string x = [0,1,1,1,2] for example (it must always begin with 0) and a parameter j, say 2, and outputs a string (x = [0, 1, 2, 2, 2, 2, 2, 3] in this example).

It does this in two steps: First it decomposes some number m into a multiple of j and a remainder.  Then it runs this decomposition through a function on the rtn.append line.  

Notice that this has cj - 1 terms where c is the number of terms in the input string and j is the parameter.  Normally, we would like it to be able to calculate cj terms.  This is an issue with the function that I am more than happy to put aside for the moment.

My key interest is to be able to make this program usable for someone who has no knowledge of programming.  In particular, I need some kind of user interface that prompts the user to input a string (ideally just by putting in numbers in the form 011123334 for example) and a parameter, and then displays the output sequence.  This is essentially what the program already does but the idea is to make it usable for even the most technologically disinclined.  Ideally it would do this without needing to run Python at all.  If anyone is able to make this happen in Python I would be eternally grateful. 



More information about the Python-list mailing list