[Tutor] Need to write a python and call it within a python main program
Kermit Rose
kermit at polaris.net
Sat Feb 18 04:09:05 CET 2006
I need to write a function that modifies its 4 imput values,
a,b,c,d according to the following rules.
set j = 8 * mod(a,2) + 4 * mod(b,2) + 2 * mod(c,2) + mod(d,2)
if j = 0, a,b,c,d = a/2,b/2,c/2,d/2
if j = 1, a,b,c,d = -1,-1,-1,-1
if j = 2, a,b,c,d = a,b/2,c,d/2
if j = 3, a,b,c,d = a,(a+b)/2,c,(d-c)/2
if j = 4, a,b,c,d = a,b,c/2,d/2
if j = 5, a,b,c,d = a,b,(a+c)/2,(d-b)/2
if j = 6, a,b,c,d = b,a,d,c
if j = 7, a,b,c,d = b,a,d,c
if j = 8, a,b,c,d = -1,-1,-1,-1
if j = 9, a,b,c,d = 2*a,a+b,a+c,(d-a-b-c)/2
if j = 10, a,b,c,d = b,a,d,c
if j = 11, a,b,c,d = 2*a,a+b,c,(d-c)/2
if j = 12, a,b,c,d = b,a,d,c
if j = 13, a,b,c,d = 2*a,b,a+c,(d-b)/2
if j = 14, a,b,c,d = b,a,d,c
if j = 15, a,b,c,d = a,a+b,a+c,d-a-b-c
I also need to find out how to write the main program that calls this
function repeatedly, testing
the output values for the solution to the equation.
Kermit < kermit at polaris.net >
More information about the Tutor
mailing list