[Tutor] Problems with subtraction!
Evert Rol
evert.rol at gmail.com
Wed Jul 7 13:59:52 CEST 2010
> The second number should be negative ( I WANT it to be negative). For example:
>
> print (0 - t[4])*(t[3] - t[5]) , (0 - t[5])*(t[2] - t[4]) gives :
>
> -30895 -935636
>
> And in the python shell:
>
> >>> -30895 -935636
> -966531
No, because you have to *subtract* the second answer from the first ( according to your print statement: print (0 - t[4])*(t[3] - t[5]) - (0 - t[5])*(t[2] - t[4]) ). So:
>>> -30895 - -935636
904741
If you want it to be negative, check the order of your coordinates: maybe you need to interchange two variables between one set of parentheses. Or maybe you need to subtract absolute values instead (sorry, too lazy to do the math to find out what is correct).
More information about the Tutor
mailing list