help with negative numbers please
Bernhard Reiter
bernhard at alpha1.csd.uwm.edu
Mon Dec 20 16:42:55 EST 1999
On 20 Dec 1999 02:05:11 GMT, Terry Reedy <tjreedy at udel.edu> wrote:
>In article <83jd7t$mi1$1 at hardcore.ivn.net>, jmace at ior.com says...
>>
>>This is a really quick question from an extreme newbie, after all I'm only
>>14. If I have an equation like this: y = z - x. How can I get y to equal
>>either a negative or positive number.
>Put the equation in your code as you wrote it. If this does not answer your
>question, rephrase it.
Yes, the question is not quite clear.
Let me explain a bit. "y" is only one variable, you tell the python
program: please take the value z stands for and substract the value x
stands for and save it in y.
y = z - x
If you then need another value you can fill a different variable.
y2 = -(z - x)
Okay, let's assume you want to be sure that y1 contains the positive
difference and y2 the negative difference, you can try:
y1 = abs(z-x)
y2 = - y1
This should give you some clues.
Bernhard
--
Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard)
Free Software Projects and Consulting (intevation.net)
Association for a Free Informational Infrastructure (ffii.org)
More information about the Python-list
mailing list