Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51238

Creating a Simple User Interface for a Function

Newsgroups comp.lang.python
Date 2013-07-25 09:03 -0700
Message-ID <cebb4f86-c546-4283-a839-46393571cbb0@googlegroups.com> (permalink)
Subject Creating a Simple User Interface for a Function
From CTSB01 <scott.moore270@gmail.com>

Show all headers | View raw


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. 

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Creating a Simple User Interface for a Function CTSB01 <scott.moore270@gmail.com> - 2013-07-25 09:03 -0700
  Re: Creating a Simple User Interface for a Function Dave Angel <davea@davea.name> - 2013-07-25 15:19 -0400
    Re: Creating a Simple User Interface for a Function CTSB01 <scott.moore270@gmail.com> - 2013-07-25 13:58 -0700
      Re: Creating a Simple User Interface for a Function Terry Reedy <tjreedy@udel.edu> - 2013-07-25 19:00 -0400
      Re: Creating a Simple User Interface for a Function Dave Angel <davea@davea.name> - 2013-07-25 19:01 -0400
      Re: Creating a Simple User Interface for a Function Terry Reedy <tjreedy@udel.edu> - 2013-07-25 19:46 -0400
      RE: Creating a Simple User Interface for a Function "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2013-07-26 14:08 +0000

csiph-web