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


Groups > comp.lang.python > #40112

Re: How would you do this?

Date 2013-02-28 01:29 -0500
From Dave Angel <davea@davea.name>
Subject Re: How would you do this?
References <0318f314-91e5-472a-a664-054ca7ea5097@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2638.1362032972.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 02/27/2013 10:32 PM, eli m wrote:
> How would you find the slope, y intercept, and slope-intercept form equation for a line in python?
>

First, I'd form a more complete description of the problem.  Specify 
what the overall constraints are (eg. Python version, OS portability, 
where input is to be gotten, and what the input values are to mean, how 
results are to be represented)

Then, I'd write a series of tests, especially showing both parameters 
that will work, and parameters that should give exceptions.

Then, I'd break the problem description into steps in a pseudo code 
form.  For example, maybe get the input parameters (which are they, and 
in what order) from the command line. Validate the inputs, and make sure 
an answer is possible.  Then apply this formula, and print the result. 
Apply that formula and print the result.  Apply the third formula and 
print the result.  Exit the program.

Next, I'd translate that pseudo code into actual Python statements, and 
type it into a text editor.

Then run those tests, and for each that fails, either revise the test or 
the code, depending on which is wrong.

If you run into trouble on one of these steps, show us your work, and 
somebody will undoubtedly be able to help there.

-- 
DaveA

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


Thread

How would you do this? eli m <techgeek201@gmail.com> - 2013-02-27 19:32 -0800
  Re: How would you do this? Dave Angel <davea@davea.name> - 2013-02-28 01:29 -0500
  Re: How would you do this? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-28 06:44 +0000
  Re: How would you do this? Michael Torrie <torriem@gmail.com> - 2013-02-27 23:52 -0700

csiph-web