ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
Re: [Tutor] finding factorials
by Payal Rathod other posts by this author
Jul 1 2003 2:39AM messages near this date
Re: [Tutor] finding factorials | Re: [Tutor] finding factorials
On Mon, Jun 30, 2003 at 10:33:36AM -0700, Danny Yoo wrote:
>  Same mistake as last time.  *grin* The code is simply dropping the value
>  that you're calculating from doing euclid().  We need to capture that
>  value:

Sorry Danny I am still not getting it. Now I am so confused that I think
I don't know what exactly a function does and what is it it returns.

I have posted my code below with some comments regarding issues I don't
get.

#!/usr/local/bin/python

def euclid(a,b):
        while b != 0:
                c = a
                a = b
                b = c % a
                print 'A = ', a
                print 'B = ', b
                return euclid(a,b)
# What will this return exactly?
        else:
                return a

x = 100
y = 20

result = euclid(x, y)

# Why do we define x and y here seperately?
# Can't we have result = euclid(100,20)
# This apparently is not working. 

print x
print y

# This always prints 100 and 20. I think it should print the present values
# of x and y which are not 100 and 20 always.

print result

# The result is given as 20 which I think is wrong. Is there anything 
# wrong with my mathematical logic or my function?

With warm regards,
-Payal


-- 
"Visit GNU/Linux Success Stories"
http://payal.staticky.com
Guest-Book Section Updated.

_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Payal Rathod
lonetwin
Kristoffer Erlandsson
Payal Rathod
Gregor Lingl
Danny Yoo
Payal Rathod
Danny Yoo
Gregor Lingl
Danny Yoo

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved