Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57949
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: First day beginner to python, add to counter after nested loop |
| Date | 2013-10-29 18:09 +0000 |
| Organization | Norwich University |
| Message-ID | <bdabtuFgst9U2@mid.individual.net> (permalink) |
| References | <4d1c9a55-310b-41b7-8271-435fd095ce70@googlegroups.com> |
On 2013-10-29, jonas.thornvall@gmail.com <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
>
><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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 10:40 -0700
Re: First day beginner to python, add to counter after nested loop Neil Cerutti <neilc@norwich.edu> - 2013-10-29 18:09 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 11:23 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 11:35 -0700
Re: First day beginner to python, add to counter after nested loop Dave Angel <davea@davea.name> - 2013-10-29 19:24 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 13:08 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-29 13:11 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-29 20:37 +0000
Re: First day beginner to python, add to counter after nested loop Dave Angel <davea@davea.name> - 2013-10-30 01:44 +0000
Re: First day beginner to python, add to counter after nested loop Ned Batchelder <ned@nedbatchelder.com> - 2013-10-29 16:30 -0400
Re: First day beginner to python, add to counter after nested loop Neil Cerutti <neilc@norwich.edu> - 2013-10-29 20:32 +0000
Re: First day beginner to python, add to counter after nested loop Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-10-30 11:53 +1300
Re: First day beginner to python, add to counter after nested loop Tim Roberts <timr@probo.com> - 2013-10-30 00:07 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 01:52 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 02:48 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 02:52 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 10:00 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:13 -0700
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 05:08 -0700
Re: First day beginner to python, add to counter after nested loop Ned Batchelder <ned@nedbatchelder.com> - 2013-10-30 08:51 -0400
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:42 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:08 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:11 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 03:19 -0700
Re: First day beginner to python, add to counter after nested loop alex23 <wuwei23@gmail.com> - 2013-11-01 11:05 +1000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 07:24 -0700
Re: First day beginner to python, add to counter after nested loop Chris Angelico <rosuav@gmail.com> - 2013-10-30 21:42 +1100
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 14:07 +0000
Re: First day beginner to python, add to counter after nested loop Tim Roberts <timr@probo.com> - 2013-11-02 13:19 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-11-03 12:33 +0100
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-11-03 04:54 -0800
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-11-03 04:55 -0800
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 13:01 +0100
Re: First day beginner to python, add to counter after nested loop Grant Edwards <invalid@invalid.invalid> - 2013-10-30 15:50 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:54 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 19:59 +0100
Re: First day beginner to python, add to counter after nested loop Chris Angelico <rosuav@gmail.com> - 2013-10-30 23:17 +1100
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 13:42 +0100
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 14:22 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 07:31 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 15:09 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:35 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:51 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 15:51 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 09:14 -0700
Re: First day beginner to python, add to counter after nested loop Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-30 16:47 -0400
Re: First day beginner to python, add to counter after nested loop alex23 <wuwei23@gmail.com> - 2013-11-01 11:07 +1000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 08:53 -0700
Re: First day beginner to python, add to counter after nested loop Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2013-10-30 22:00 +0530
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 09:45 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 15:54 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 08:57 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 16:13 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-30 09:16 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 16:38 +0000
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 16:22 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 09:31 -0700
Re: First day beginner to python, add to counter after nested loop MRAB <python@mrabarnett.plus.com> - 2013-10-30 17:44 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 10:55 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 11:02 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 20:09 +0100
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:16 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 19:01 +0100
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 11:43 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 19:05 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:13 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 20:59 +0100
Re: First day beginner to python, add to counter after nested loop Ned Batchelder <ned@nedbatchelder.com> - 2013-10-30 16:52 -0400
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 22:07 +0100
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 00:37 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-31 10:11 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 04:07 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-11-01 11:17 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-11-01 09:52 -0700
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-31 12:12 +0100
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 04:40 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-31 14:01 +0000
Re: First day beginner to python, add to counter after nested loop rusi <rustompmody@gmail.com> - 2013-10-31 08:30 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 11:55 -0700
Re: First day beginner to python, add to counter after nested loop Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-30 19:26 +0000
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:38 -0700
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 12:41 -0700
Re: First day beginner to python, add to counter after nested loop Dave Angel <davea@davea.name> - 2013-10-31 03:02 +0000
Re: First day beginner to python, add to counter after nested loop Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-30 16:50 -0400
Re: First day beginner to python, add to counter after nested loop jonas.thornvall@gmail.com - 2013-10-30 09:19 -0700
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 15:15 +0000
Re: First day beginner to python, add to counter after nested loop Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-10-30 15:56 +0100
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 16:07 +0000
Re: First day beginner to python, add to counter after nested loop Alister <alister.ware@ntlworld.com> - 2013-10-30 16:14 +0000
Re: First day beginner to python, add to counter after nested loop rurpy@yahoo.com - 2013-10-30 10:02 -0700
csiph-web