question from a newbie:
can somebody help me in converting this c++ code to python...
[CODE=c]
bool flag;
do{
flag=0;
for(int i=0;i<n;i++){
double s1=xold[i];
double s2=xnew[i];
e[i]= s1-s2;
if (e[i]<0) {e[i]=0-e[i];}
if(e[i]>prec){flag=1 ;}
for(int i=0;i<n;i++){
xold[i]=xnew[i];
}
}
}while (flag);
[/CODE]
basically the bool thing is a prob... also if i hav created a function(say solve(parameter s)) within a function(say display(paramet ers)).... then the python code goes sumwat like this:
can somebody help me in converting this c++ code to python...
[CODE=c]
bool flag;
do{
flag=0;
for(int i=0;i<n;i++){
double s1=xold[i];
double s2=xnew[i];
e[i]= s1-s2;
if (e[i]<0) {e[i]=0-e[i];}
if(e[i]>prec){flag=1 ;}
for(int i=0;i<n;i++){
xold[i]=xnew[i];
}
}
}while (flag);
[/CODE]
basically the bool thing is a prob... also if i hav created a function(say solve(parameter s)) within a function(say display(paramet ers)).... then the python code goes sumwat like this:
Code:
def display(parameter1, parameter2): {code of display} solve(parameter3, parameter4): {code of solve and it gives me output its output in the form of a number} #now i want to return control to display {remaining code of display continues...}
Comment