On Thu, Jul 19, 2012 at 4:21 PM, Dave Angel wrote:
> On 07/19/2012 06:58 PM, Alexander Q. wrote:
> > I have this little program that is supposed to calculate how many
> diagonals
> > a polygon of x sides has, but it does not return what I have in the
> > "return" part of the function when I call
On 20/07/12 00:17, Prasad, Ramit wrote:
def num_diag(var):
ans = 0
if var <= 3:
print("No diagonals.")
else:
for i in range(num_sides - 3):
ans = ans + i
return (((var - 3)*2) + ans)
num_sides = (int(raw_input("Enter sides: ")))
num_diag(num_sides)
NameError:
On 07/19/2012 06:58 PM, Alexander Q. wrote:
> I have this little program that is supposed to calculate how many diagonals
> a polygon of x sides has, but it does not return what I have in the
> "return" part of the function when I call it. Here is the code:
>
> def num_diag(var):
> ans = 0
> if
On 7/19/2012 3:58 PM Alexander Q. said...
I have this little program that is supposed to calculate how many
diagonals a polygon of x sides has, but it does not return what I have
in the "return" part of the function when I call it. Here is the code:
def num_diag(var):
ans = 0
if var <= 3:
> I have this little program that is supposed to calculate how many diagonals a
> polygon of x sides has, but it does not return what I have in the "return"
> part of the function when I call it. Here is the code:
>
> def num_diag(var):
> ans = 0
> if var <= 3:
> print("No diagonals.")
>
I have this little program that is supposed to calculate how many diagonals
a polygon of x sides has, but it does not return what I have in the
"return" part of the function when I call it. Here is the code:
def num_diag(var):
ans = 0
if var <= 3:
print("No diagonals.")
else:
for i i
"Trey Keown" <[EMAIL PROTECTED]> wrote
> I'm creating a module for my program, and I need to call a function.
> Here's how it's set up:
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> class DoStuff:
>def Thing1(self):
>def ThingToCall(self):
>print "It worke
Trey Keown wrote:
> Hey all...
> I'm creating a module for my program, and I need to call a function.
> Here's how it's set up:
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> class DoStuff:
> def Thing1(self):
> def ThingToCall(self):
> print "It worked!"
>
Hey all...
I'm creating a module for my program, and I need to call a function.
Here's how it's set up:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
class DoStuff:
def Thing1(self):
def ThingToCall(self):
print "It worked!"
def Thing2(self):
#Call
nal Message-From: Michael P.
Reilly [mailto:[EMAIL PROTECTED] Sent: Friday, July 21, 2006 1:36
PMTo: Smith, JeffCc: tutor@python.orgSubject:
Re: [Tutor] Calling a function by string nameOn
7/21/06, Smith, Jeff <[EMAIL PROTECTED]> wrote:
I have an object and
On 7/21/06, Smith, Jeff <[EMAIL PROTECTED]> wrote:
I have an object and
I want to call a method that I have constructed the name for in a
string.
For
example:
str_method =
'myfun'
obj.str_method
Of course, this
fails. I know I could probably do this with exec but is there a better
Smith, Jeff wrote:
> I have an object and I want to call a method that I have constructed
> the name for in a string.
>
> For example:
> str_method = 'myfun'
> obj.str_method
>
> Of course, this fails. I know I could probably do this with exec but
> is there a better way?
Use getattr():
get
Title: Message
I have an object and
I want to call a method that I have constructed the name for in a
string.
For
example:
str_method =
'myfun'
obj.str_method
Of course, this
fails. I know I could probably do this with exec but is there a better
way?
For context, the
specific appli
On Jun 9, 2005, at 07:45, Kevin Reeder wrote:
> I'm having trouble with this code which is meant to run a time
> comparison between two similar functions. The first module is
> makezeros.py
>
> def lots_of_appends():
> zeros = []
> for i in range(1):
> zeros.append(0)
>
> def one_
Kevin Reeder said:
>def do_timing(num_times, *funcs):
Took me a while to work out what went wrong, but the first part occurs here.
The *funcs bit means that any extra arguments passed to do_timing will be put
into a tuple called funcs.
So do_timing(100, dosomething, dosomethingelse)
will pass
Ewald & John,
thanks for the help. i'll work on it some more with your ideas in
mind (after getting some sleep).
Kevin
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Quoting Kevin Reeder <[EMAIL PROTECTED]>:
> The second module is timings.py.
>
> import time, makezeros
>
> def do_timing(num_times, *funcs):
> totals = {}
> for func in funcs: totals[func] = 0.0
> for x in range(num_times):
> for func in funcs:
>starttime = time.time()
>
Hi!
I don't know if I'm right here, because I've tested a simple model of what
you're
trying to do:
on Wed, 8 Jun 2005 23:45:59 -0700 Kevin Reeder <[EMAIL PROTECTED]> wrote :
-
Kevin Reeder > import t
I'm having trouble with this code which is meant to run a time
comparison between two similar functions. The first module is
makezeros.py
def lots_of_appends():
zeros = []
for i in range(1):
zeros.append(0)
def one_multiply():
zeros = [0] * 10
19 matches
Mail list logo