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.thornv...@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? -- https://mail.python.org/mailman/listinfo/python-list