Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: First day beginner to python, add to counter after nested loop Date: 29 Oct 2013 18:09:03 GMT Organization: Norwich University Lines: 81 Message-ID: References: <4d1c9a55-310b-41b7-8271-435fd095ce70@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net ULyQ/qWs5L8Q5hGN2GexbAfNcWFbD6TopRBdrr8ClrpOhuhh+v Cancel-Lock: sha1:JFqbqmHRVHHZ94kvcAybkzdPEUM= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:57949 On 2013-10-29, jonas.thornvall@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 > > >TEST > > > > What on does function sq do? Squank? Squarp? Squijel? For number 7, I'm thinking I get output: 7 = 2 + 3 -- Neil Cerutti