On 2013-10-29, jonas.thornv...@gmail.com <jonas.thornv...@gmail.com> wrote: > I have a 25 row javascript that i try to convert to python to get into the > language but i run into problem i do not understand howto reach outer loop > after finnish inner loop, in fact i do not understand when finished. The > javascript i try to conver is below. > > #!/usr/bin/python > import math > # Function definition is here > def sq(number): > > square=1; > factor=2; > exponent=2; > print(x,"= "); > while (number>3): > while (square<=number): > factor+=1; > square=math.pow(factor,exponent); > ----now i want to add conter when loop finished, no end like basic???? > ??? factor--; > ??? print(factor," "); > ??? square=math.pow(factor,exponent); > ??? number=number-(factor*factor); > ??? square=1; > ??? factor=1; > ---here does second loop finish > return > > print("Exp=x^2"); > for x in range (22,23): > sq(x); > > > > Here is the javascript with loop i try to convert.
Output: 7 = 2 + 3 number square factor exponent 7 1 2 2 9 3 3 1 1 > ><HTML> ><HEAD><TITLE>TEST</TITLE></HEAD> ><SCRIPT language=Javascript> > function sq(number){ > square=1; > factor=2; > exponent=2; > document.write(x,"= "); > while (number>3) { > while (square<=number) { > factor++; > square=Math.pow(factor,exponent); > } > factor--; > document.write(factor," "); > square=Math.pow(factor,exponent); > number=number-(factor*factor); > square=1; > factor=1; > } > document.write("+",number,"<BR>"); > } > document.write("Exp=x^2<BR>"); > for (x=1;x<100;x++){ > sq(x); > } ></script> ><BODY> ></BODY> ></HTML> What on does function sq do? Squank? Squarp? Squijel? For number 7, I'm thinking I get output: 7 = 2 + 3 -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list