Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57940 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2013-10-29 10:40 -0700 |
| Last post | 2013-10-30 10:02 -0700 |
| Articles | 20 on this page of 90 — 17 participants |
Back to article view | Back to comp.lang.python
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
Page 1 of 5 [1] 2 3 4 5 Next page →
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-29 10:40 -0700 |
| Subject | First day beginner to python, add to counter after nested loop |
| Message-ID | <4d1c9a55-310b-41b7-8271-435fd095ce70@googlegroups.com> |
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.
<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>
[toc] | [next] | [standalone]
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Date | 2013-10-29 18:09 +0000 |
| Message-ID | <bdabtuFgst9U2@mid.individual.net> |
| In reply to | #57940 |
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
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-29 11:23 -0700 |
| Message-ID | <7e0b17ea-3a79-45e7-aefc-795f3f34af95@googlegroups.com> |
| In reply to | #57949 |
Den tisdagen den 29:e oktober 2013 kl. 19:09:03 UTC+1 skrev Neil Cerutti:
> 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
It write out numbers on modular? square form, just copy past the HTML embedded javascript into text, save as HTML run i brower and you see.
Decimal base
1234=1000+200+30+4 i bad at terminiology but let us call modular base 10 form.
The script convert to modular square form number and write out.
1234= 35 3 +0
35^2 + 3^3 = 1225 + 9 =1234
It is very basic
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-29 11:35 -0700 |
| Message-ID | <c34faa00-71b2-4257-8427-e318356f9bd2@googlegroups.com> |
| In reply to | #57951 |
Den tisdagen den 29:e oktober 2013 kl. 19:23:28 UTC+1 skrev jonas.t...@gmail.com:
> Den tisdagen den 29:e oktober 2013 kl. 19:09:03 UTC+1 skrev Neil Cerutti:
>
> > 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
>
>
>
> It write out numbers on modular? square form, just copy past the HTML embedded javascript into text, save as HTML run i brower and you see.
>
>
>
> Decimal base
>
> 1234=1000+200+30+4 i bad at terminiology but let us call modular base 10 form.
>
>
>
> The script convert to modular square form number and write out.
>
> 1234= 35 3 +0
>
> 35^2 + 3^3 = 1225 + 9 =1234
>
>
>
> It is very basic
And it work for any exponential form square, cubic etc. I want to implement in python since javascript lack bignumb, and diskread write function.
Exp=x^2
7777777777= 88191 353 26 3 +2
Exp=x^3
7777777777= 1981 153 33 10 4 3 3 +4
Exp=x^4
7777777777= 296 100 33 12 9 5 4 3 3 2 2 2 +12
Exp=x^5
7777777777= 95 33 15 9 6 5 5 3 3 2 2 +9
Exp=x^6
7777777777= 44 28 18 13 9 7 6 5 5 4 3 3 3 3 2 2 2 2 2 2 2 2 +64
Exp=x^7
7777777777= 25 20 16 14 11 7 5 4 3 3 3 2 2 2 2 2 2 2 2 2 2 +128
Exp=x^8
7777777777= 17 12 11 10 9 7 7 6 5 5 5 4 4 4 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 +33
Exp=x^9
7777777777= 12 11 8 7 7 7 5 5 4 4 4 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 +510
Exp=x^10
7777777777= 9 9 7 7 6 6 6 5 5 5 5 5 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 +502
Exp=x^11
Here is code for doing it for any exponent.
<HTML>
<HEAD><TITLE>TEST</TITLE></HEAD>
<SCRIPT language=Javascript>
function sq(number,exponent){
exp=1;
factor=2;
multip=Math.pow(2,exponent);
document.write(x,"= ");
while (number>multip){
while (exp<=number)
{ factor++;
exp=Math.pow(factor,exponent);
}
factor--;
document.write(factor," ");
exp=Math.pow(factor,exponent);
number=number-Math.pow(factor,exponent);
exp=1;
factor=1;
}
document.write("+",number,"<BR>");
}
//Set exponent by change y
y=10;
x=7777777777
for (y=2;y<20;y++){
document.write("Exp=x^",y,"<BR>");
sq(x,y);
}
</script>
<BODY>
</BODY>
</HTML>
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-10-29 19:24 +0000 |
| Message-ID | <mailman.1772.1383074721.18130.python-list@python.org> |
| In reply to | #57956 |
On 29/10/2013 14:35, jonas.thornvall@gmail.com wrote:
(Deleting hundreds of quad-spaced garbage. Please be more considerate
of others if you choose to use buggy googlegroups, maybe starting by
studying:
)
Please indent by 4 columns, not 1. Since indentation is how scope is
specified in Python, it's very important to get it right.
> i do not understand howto reach outer loop after finnish inner loop, in fact i do not understand when finished.
The inner loop is finished whenever you stop indenting by 8 columns. If
you have a fundamental problem like this, keep it simple till you
understand it:
q = 12
for x in range(10):
for y in range(3):
q = 3*q + 1
print("inner", q)
print("outer", x*q)
print("done")
Because of the detenting, the print("outer", x*q) is in the outer loop.
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-29 13:08 -0700 |
| Message-ID | <20e6a79f-2d0e-4e78-8af6-607375eca676@googlegroups.com> |
| In reply to | #57962 |
Den tisdagen den 29:e oktober 2013 kl. 20:24:57 UTC+1 skrev Dave Angel:
> On 29/10/2013 14:35, jonas.thornvall@gmail.com wrote:
>
>
>
> (Deleting hundreds of quad-spaced garbage. Please be more considerate
>
> of others if you choose to use buggy googlegroups, maybe starting by
>
> studying:
>
>
>
> )
>
>
>
> Please indent by 4 columns, not 1. Since indentation is how scope is
>
> specified in Python, it's very important to get it right.
>
>
>
> > i do not understand howto reach outer loop after finnish inner loop, in fact i do not understand when finished.
>
>
>
> The inner loop is finished whenever you stop indenting by 8 columns. If
>
> you have a fundamental problem like this, keep it simple till you
>
> understand it:
>
>
>
>
>
> q = 12
>
> for x in range(10):
>
> for y in range(3):
>
> q = 3*q + 1
>
> print("inner", q)
>
> print("outer", x*q)
>
>
>
> print("done")
>
>
>
> Because of the detenting, the print("outer", x*q) is in the outer loop.
>
>
>
>
>
> --
>
> DaveA
Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code.
Got the script working though :D, good start. It seem though that Python automaticly add linebreaks after printout. Is there a way to not have print command change line? Or must i build up a string/strings for later printout?
#!/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);
factor-=1;
print(factor,"^2");
square=math.pow(factor,exponent);
number=number-(factor*factor);
square=1;
factor=1;
print("+",number);
return
print("Exp=x^2");
for x in range (21,22):
sq(x);
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-29 13:11 -0700 |
| Message-ID | <cd302a19-e76c-4255-bd61-eecf38b2520e@googlegroups.com> |
| In reply to | #57967 |
Den tisdagen den 29:e oktober 2013 kl. 21:08:39 UTC+1 skrev jonas.t...@gmail.com:
> Den tisdagen den 29:e oktober 2013 kl. 20:24:57 UTC+1 skrev Dave Angel:
>
> > On 29/10/2013 14:35, jonas.thornvall@gmail.com wrote:
>
> >
>
> >
>
> >
>
> > (Deleting hundreds of quad-spaced garbage. Please be more considerate
>
> >
>
> > of others if you choose to use buggy googlegroups, maybe starting by
>
> >
>
> > studying:
>
> >
>
> >
>
> >
>
> > )
>
> >
>
> >
>
> >
>
> > Please indent by 4 columns, not 1. Since indentation is how scope is
>
> >
>
> > specified in Python, it's very important to get it right.
>
> >
>
> >
>
> >
>
> > > i do not understand howto reach outer loop after finnish inner loop, in fact i do not understand when finished.
>
> >
>
> >
>
> >
>
> > The inner loop is finished whenever you stop indenting by 8 columns. If
>
> >
>
> > you have a fundamental problem like this, keep it simple till you
>
> >
>
> > understand it:
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > q = 12
>
> >
>
> > for x in range(10):
>
> >
>
> > for y in range(3):
>
> >
>
> > q = 3*q + 1
>
> >
>
> > print("inner", q)
>
> >
>
> > print("outer", x*q)
>
> >
>
> >
>
> >
>
> > print("done")
>
> >
>
> >
>
> >
>
> > Because of the detenting, the print("outer", x*q) is in the outer loop.
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> > DaveA
>
>
>
>
>
> Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code.
>
>
>
> Got the script working though :D, good start. It seem though that Python automaticly add linebreaks after printout. Is there a way to not have print command change line? Or must i build up a string/strings for later printout?
>
>
>
> #!/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);
>
> factor-=1;
>
> print(factor,"^2");
>
> square=math.pow(factor,exponent);
>
> number=number-(factor*factor);
>
> square=1;
>
> factor=1;
>
> print("+",number);
>
> return
>
>
>
> print("Exp=x^2");
>
> for x in range (21,22):
>
> sq(x);
They could had used print and prinln from basic? I do not want new line everytime i write out some terms. And i do not like it add extra space after each print of variable print(factor,"^2") writes out 12 ^2 and i do not think there is any space after the factor?
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-10-29 20:37 +0000 |
| Message-ID | <mailman.1775.1383079076.18130.python-list@python.org> |
| In reply to | #57969 |
On 29/10/2013 20:11, jonas.thornvall@gmail.com wrote: > > I do not want new line everytime i write out some terms. > I wish you'd apply that thinking to your posts. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-10-30 01:44 +0000 |
| Message-ID | <mailman.1784.1383097480.18130.python-list@python.org> |
| In reply to | #57969 |
On 29/10/2013 16:11, jonas.thornvall@gmail.com wrote:
> Den tisdagen den 29:e oktober 2013 kl. 21:08:39 UTC+1 skrev jonas.t...@gmail.com:
>> Den tisdagen den 29:e oktober 2013 kl. 20:24:57 UTC+1 skrev Dave Angel:
>
> They could had used print and prinln from basic? I do not want new line everytime i write out some terms.
That's ironic, when the bulk of your message is quad-spaced --- three
blank lines between every useful line. Please reread:
http://wiki.python.org/moin/GoogleGroupsPython
> And i do not like it add extra space after each print of variable
print(factor,"^2") writes out 12 ^2 and i do not think there is any space after the factor?
Look up the print function, and see all the keyword options. Two in
particular:
sep=
end=
would address both your concerns.
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2013-10-29 16:30 -0400 |
| Message-ID | <mailman.1774.1383078644.18130.python-list@python.org> |
| In reply to | #57967 |
On 10/29/13 4:08 PM, jonas.thornvall@gmail.com wrote: > Why did Python not implement end... The end is really not necessary for the programming language it can be excluded, but it is a courtesy to the programmer and could easily be transformed to indents automaticly, that is removed before the compiliation/interpretation of code. If you're going to indent your code correctly anyway, then the "end"s are just extra noise. And if you aren't going to indent your code to match the structure, then you have two different channels of information: the human pays attention to the indentation, and the computer pays attention to the ends. That's a recipe for creating lots of subtle bugs. You get used to reading the indentation. > They could had used print and prinln from basic? I do not want new line everytime i write out some terms. And i do not like it add extra space after each print of variable print(factor,"^2") writes out 12 ^2 and i do not think there is any space after the factor? > The print statement is very simple, and has not had a lot of features added to it, because you very quickly outgrow it anyway. If you want fine control over the output of your program, you use string formatting, for example with the .format() method on strings. --Ned.
[toc] | [prev] | [next] | [standalone]
| From | Neil Cerutti <neilc@norwich.edu> |
|---|---|
| Date | 2013-10-29 20:32 +0000 |
| Message-ID | <bdakbiFjem2U1@mid.individual.net> |
| In reply to | #57967 |
On 2013-10-29, jonas.thornvall@gmail.com
<jonas.thornvall@gmail.com> wrote:
> Got the script working though :D, good start. It seem though
> that Python automaticly add linebreaks after printout. Is there
> a way to not have print command change line? Or must i build up
> a string/strings for later printout?
print takes an keyword argument, called end, that defaults to
"\n". You can provide something else:
print("xzzz", end="")
> #!/usr/bin/python
> import math
> # Function definition is here
> def sq(number):
> square=1;
Get in the habit of not using the semicolon to end lines. Python
doesn't need them, except when two statements appear without a
newline between them.
> factor=2;
> exponent=2;
> print(x,"= ");
That ought to be
print(number, "= ", end="")
There's no need to refer to global x when you've passed it in as
number.
> while (number>3):
> while (square<=number):
> factor+=1;
> square=math.pow(factor,exponent);
You don't want to use math.pow. Just use pow or the ** operator.
square = factor**exponent
> factor-=1;
> print(factor,"^2");
> square=math.pow(factor,exponent);
> number=number-(factor*factor);
Analogous with factor += 1, you can do
number -= factor * factor
Note the usual spacing of python operators and identifiers.
> square=1;
> factor=1;
> print("+",number);
> return
A bare return at the end of a Python function is not needed. All
functions return None if they fall off the end.
--
Neil Cerutti
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2013-10-30 11:53 +1300 |
| Message-ID | <bdask3Fl5t8U2@mid.individual.net> |
| In reply to | #57972 |
Neil Cerutti wrote: > Get in the habit of not using the semicolon to end lines. Also, you don't need to put parentheses around the conditions of while and if statements. -- Greg
[toc] | [prev] | [next] | [standalone]
| From | Tim Roberts <timr@probo.com> |
|---|---|
| Date | 2013-10-30 00:07 -0700 |
| Message-ID | <mtb179dmhre6mh7bnh8om7gbodb5j70ln6@4ax.com> |
| In reply to | #57967 |
jonas.thornvall@gmail.com wrote: > >Why did Python not implement end... The end is really not necessary for >the programming language it can be excluded, but it is a courtesy to >the programmer and could easily be transformed to indents automaticly, >that is removed before the compiliation/interpretation of code. You only say that because your brain has been poisoned by languages that require some kind of "end". It's not necessary, and it's extra typing. 99% of programmers do the indentation anyway, to make the program easy to read, so why not just make it part of the syntax? That way, you don't accidentally have the indentation not match the syntax. -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-30 01:52 -0700 |
| Message-ID | <fb110254-2a54-4ab7-820c-a05c0882c49b@googlegroups.com> |
| In reply to | #58009 |
Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts: > jonas.thornvall@gmail.com wrote: > > > > > >Why did Python not implement end... The end is really not necessary for > > >the programming language it can be excluded, but it is a courtesy to > > >the programmer and could easily be transformed to indents automaticly, > > >that is removed before the compiliation/interpretation of code. > > > > You only say that because your brain has been poisoned by languages that > > require some kind of "end". It's not necessary, and it's extra typing. 99% > > of programmers do the indentation anyway, to make the program easy to read, > > so why not just make it part of the syntax? That way, you don't > > accidentally have the indentation not match the syntax. > > -- > > Tim Roberts, timr@probo.com > > Providenza & Boekelheide, Inc. It maybe common practice in program languages, but to me it is slightly confusing to have the while/for loop on the same indent level, as the regular statements. Because when the while loop ends there is no other identification then that the indent stopped, and to me it is easy to interpret that terms that actually straight under the loop belongs to it. But of course it is a matter of adjust the way i look at the code. Thanks for help guys.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-30 02:48 -0700 |
| Message-ID | <56e77d03-45cc-49d6-a951-ee1cab3fca4d@googlegroups.com> |
| In reply to | #58013 |
Den onsdagen den 30:e oktober 2013 kl. 09:52:16 UTC+1 skrev jonas.t...@gmail.com:
> Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
>
> > jonas.thornvall@gmail.com wrote:
>
> >
>
> > >
>
> >
>
> > >Why did Python not implement end... The end is really not necessary for
>
> >
>
> > >the programming language it can be excluded, but it is a courtesy to
>
> >
>
> > >the programmer and could easily be transformed to indents automaticly,
>
> >
>
> > >that is removed before the compiliation/interpretation of code.
>
> >
>
> >
>
> >
>
> > You only say that because your brain has been poisoned by languages that
>
> >
>
> > require some kind of "end". It's not necessary, and it's extra typing. 99%
>
> >
>
> > of programmers do the indentation anyway, to make the program easy to read,
>
> >
>
> > so why not just make it part of the syntax? That way, you don't
>
> >
>
> > accidentally have the indentation not match the syntax.
>
> >
>
> > --
>
> >
>
> > Tim Roberts, timr@probo.com
>
> >
>
> > Providenza & Boekelheide, Inc.
>
>
>
> It maybe common practice in program languages, but to me it is slightly confusing to have the while/for loop on the same indent level, as the regular statements.
>
> Because when the while loop ends there is no other identification then that the indent stopped, and to me it is easy to interpret that terms that actually straight under the loop belongs to it.
>
>
>
> But of course it is a matter of adjust the way i look at the code.
>
> Thanks for help guys.
To show you guys that i am not totally uneducable i actually followed your sugestions ;D.
(Is there any support similar javascript canvas for drawing, and HTML for interactivity, textbox, buttons in python?).
I have been programming some PHP long time ago, basicly only remember you had to have a server running to interact via HTML.
#!/usr/bin/python
import math
# Function definition is here
def sq(number):
square=1
factor=2
multip=exponent*exponent
print(x,"= ", end="")
while number>=multip:
while square<=number:
factor+=1
square=factor*factor
factor-=1
print(factor,"^2+",sep="",end="")
square=factor*factor
number=number-(factor*factor)
square=1
factor=1
print(number)
#Set exponent here
exponent=3
print("Exp=x^",exponent,sep="")
#Set range of numbers x
for x in range (1,100):
sq(x);
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-30 02:52 -0700 |
| Message-ID | <7c730b3e-66ad-4835-9190-7483d7a75110@googlegroups.com> |
| In reply to | #58016 |
Den onsdagen den 30:e oktober 2013 kl. 10:48:36 UTC+1 skrev jonas.t...@gmail.com:
> Den onsdagen den 30:e oktober 2013 kl. 09:52:16 UTC+1 skrev jonas.t...@gmail.com:
>
> > Den onsdagen den 30:e oktober 2013 kl. 08:07:31 UTC+1 skrev Tim Roberts:
>
> >
>
> > > jonas.thornvall@gmail.com wrote:
>
> >
>
> > >
>
> >
>
> > > >
>
> >
>
> > >
>
> >
>
> > > >Why did Python not implement end... The end is really not necessary for
>
> >
>
> > >
>
> >
>
> > > >the programming language it can be excluded, but it is a courtesy to
>
> >
>
> > >
>
> >
>
> > > >the programmer and could easily be transformed to indents automaticly,
>
> >
>
> > >
>
> >
>
> > > >that is removed before the compiliation/interpretation of code.
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > You only say that because your brain has been poisoned by languages that
>
> >
>
> > >
>
> >
>
> > > require some kind of "end". It's not necessary, and it's extra typing. 99%
>
> >
>
> > >
>
> >
>
> > > of programmers do the indentation anyway, to make the program easy to read,
>
> >
>
> > >
>
> >
>
> > > so why not just make it part of the syntax? That way, you don't
>
> >
>
> > >
>
> >
>
> > > accidentally have the indentation not match the syntax.
>
> >
>
> > >
>
> >
>
> > > --
>
> >
>
> > >
>
> >
>
> > > Tim Roberts, timr@probo.com
>
> >
>
> > >
>
> >
>
> > > Providenza & Boekelheide, Inc.
>
> >
>
> >
>
> >
>
> > It maybe common practice in program languages, but to me it is slightly confusing to have the while/for loop on the same indent level, as the regular statements.
>
> >
>
> > Because when the while loop ends there is no other identification then that the indent stopped, and to me it is easy to interpret that terms that actually straight under the loop belongs to it.
>
> >
>
> >
>
> >
>
> > But of course it is a matter of adjust the way i look at the code.
>
> >
>
> > Thanks for help guys.
>
>
>
> To show you guys that i am not totally uneducable i actually followed your sugestions ;D.
>
> (Is there any support similar javascript canvas for drawing, and HTML for interactivity, textbox, buttons in python?).
>
>
>
> I have been programming some PHP long time ago, basicly only remember you had to have a server running to interact via HTML.
>
>
>
> #!/usr/bin/python
>
> import math
>
> # Function definition is here
>
> def sq(number):
>
>
>
> square=1
>
> factor=2
>
> multip=exponent*exponent
>
> print(x,"= ", end="")
>
> while number>=multip:
>
> while square<=number:
>
> factor+=1
>
> square=factor*factor
>
> factor-=1
>
> print(factor,"^2+",sep="",end="")
>
> square=factor*factor
>
> number=number-(factor*factor)
>
> square=1
>
> factor=1
>
> print(number)
>
>
>
> #Set exponent here
>
> exponent=3
>
> print("Exp=x^",exponent,sep="")
>
> #Set range of numbers x
>
> for x in range (1,100):
>
> sq(x);
Forgot change the static square that was written out, i am a bit undecuable afterall...
#!/usr/bin/python
import math
# Function definition is here
def sq(number):
square=1
factor=2
multip=exponent*exponent
print(x,"= ", end="")
while number>=multip:
while square<=number:
factor+=1
square=factor*factor
factor-=1
print(factor,"^",exponent,"+",sep="",end="")
square=factor*factor
number=number-(factor*factor)
square=1
factor=1
print(number)
#Set exponent here
exponent=3
print("Exp=x^",exponent,sep="")
#Set range of numbers x
for x in range (1,100):
sq(x);
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-10-30 10:00 +0000 |
| Message-ID | <mailman.1799.1383127250.18130.python-list@python.org> |
| In reply to | #58017 |
On 30/10/2013 09:52, jonas.thornvall@gmail.com wrote: Please stop sending us double spaced crap. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2013-10-30 03:13 -0700 |
| Message-ID | <5a399d24-dcfa-4e6a-a0d2-31f748729852@googlegroups.com> |
| In reply to | #58018 |
Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence: > On 30/10/2013 09:52, jonas.thornvall@gmail.com wrote: > > > > Please stop sending us double spaced crap. > > > > -- > > Python is the second best programming language in the world. > > But the best has yet to be invented. Christian Tismer > > > > Mark Lawrence I am not sure what you want. You want me to remove the empty line in function? I do it for it is easier to read for me.
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-10-30 05:08 -0700 |
| Message-ID | <cc7557e5-cf09-4ad3-8f0f-611a2ac344d5@googlegroups.com> |
| In reply to | #58021 |
On Wednesday, October 30, 2013 3:43:03 PM UTC+5:30, jonas.t...@gmail.com wrote: > Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence: * * Please stop sending us double spaced crap. * * Mark Lawrence * I am not sure what you want. And then again * You want me to remove the empty line in function? I do it for it is easier to * read for me. * I think it is not me it is probably google groups, well maybe they should * consider changing linebreak sign as stored in database. 1. Go to the python archive for this month https://mail.python.org/pipermail/python-list/2013-October/author.html#start 2. Search for your posts by control-f jonas 3. Open 4 or 4 at random and try to read them Now do you see that google-groups (stupidly) inserts extra lines that causes a lot of irritation to a lot of people?
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2013-10-30 08:51 -0400 |
| Message-ID | <mailman.1805.1383137503.18130.python-list@python.org> |
| In reply to | #58021 |
On 10/30/13 6:13 AM, jonas.thornvall@gmail.com wrote:
> Den onsdagen den 30:e oktober 2013 kl. 11:00:30 UTC+1 skrev Mark Lawrence:
>> On 30/10/2013 09:52, jonas.thornvall@gmail.com wrote:
>>
>>
>>
>> Please stop sending us double spaced crap.
>>
>>
>>
>> --
>>
>> Python is the second best programming language in the world.
>>
>> But the best has yet to be invented. Christian Tismer
>>
>>
>>
>> Mark Lawrence
> I am not sure what you want.
> You want me to remove the empty line in function? I do it for it is easier to read for me.
Jonas, he's talking about the quoted content that Google Groups includes
in your messages. Some people find this extremely aggravating.
As for your code, you should actually give it much more space:
#!/usr/bin/env python
import math
# Function definition is here
def sq(number):
square = 1
factor = 2
multip = exponent * exponent # not sure why exponent is accessed globally..
print(x, "= ", end="")
while number >= multip:
while square <= number:
factor += 1
square = factor * factor
factor -= 1
print(factor, "^", exponent, "+", sep="", end="")
number -= factor*factor
square = 1
factor = 1
print(number)
# Set exponent here
exponent = 3
print("Exp=x^", exponent, sep="")
# Set range of numbers x
for x in range (1, 100):
sq(x)
--Ned.
[toc] | [prev] | [next] | [standalone]
Page 1 of 5 [1] 2 3 4 5 Next page →
Back to top | Article view | comp.lang.python
csiph-web