john boy said unto the world upon 2005-11-12 19:43:
> OK...I have the following program
>
> i = 1
> while i <= 6:
> print 2 * i,' ',
> i = i + 1
> print
>
> this is supposed to give you a "new" blank line after the program runs
> instead it just gives:
> 2 4 6 8 10 12
>
>
On Sat, 12 Nov 2005 13:42:37 +, Max Erickson wrote:
>
> Not in python.
>
> For example, what would you call the following?
>
> def rsum(n, m):
> print n+m
> return n+m
>
>
> In python a method is callable attached to an object. A function is a
> callable object constructed with a
Max Erickson wrote:
> Not in python.
>
> For example, what would you call the following?
>
> def rsum(n, m):
> print n+m
> return n+m
>
I would call it a python function with a side-effect.
Colin W.
>
> In python a method is callable attached to an object. A function is a
> callable o
Ruben Charles wrote:
> That is the diference between a method and a function.
> A method do something and a function return something.
I'd rather say it's the difference between a procedure and a function,
as it is used in e.g. Pascal. Procedures in Pascal don't return
anything, more or less analo
Ruben Charles wrote:
> That is the diference between a method and a function.
> A method do something and a function return something.
>
This is not quite correct. The difference between a method and a
function is that the method is associated with a type or class object, a
function is not.
A m
On 11/12/05, Max Erickson <[EMAIL PROTECTED]> wrote:
>
> Not in python.
>
> For example, what would you call the following?
>
> def rsum(n, m):
> print n+m
> return n+m
>
>
> In python a method is callable attached to an object. A function is a
> callable object constructed with a def state
Not in python.
For example, what would you call the following?
def rsum(n, m):
print n+m
return n+m
In python a method is callable attached to an object. A function is a
callable object constructed with a def statement.
max
--
http://mail.python.org/mailman/listinfo/python-list
That is the diference between a method and a function.
A method do something and a function return something.
Example:
def psum(n, m):
print (n + m)
def rsum(n, m):
return (n +m)
Then try this...
>>> psum(2, 3)
>>> a = psum(2, 3)
>>> a
>>> a = rsum(2, 3)
>>> a
You see it?
--
ht
>>> import math
>>> def distance1(x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
dsquared = dx**2 + dy**2
result = math.sqrt(dsquared)
print result
return result
>>> def distance2(x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
dsquared = dx**2 + dy**2
result = math.s