[Tutor] Recursion - Beginner
Shawn Blazer
shawnblazer94 at gmail.com
Sat May 29 00:09:14 CEST 2010
Hello! I'm a high school student, and I'm having some trouble learning
recursion in my class...
For example:
Trace the sequence of recursive calls that glee(2,1) spawns:
def glee ( idol , scrub ) :
if idol == 0 :
return scrub
elif idol < 0 :
return scrub + glee ( idol + 10 , idol % 3 )
else :
return scrub + glee ( idol - scrub , idol % 3 )
Also, I'm not really sure what a question like this is asking...
>>> getLeaves ( jenny )
[5,3,0,9]
>>>
>>> getLeaves ( joshua )
[15,17,19,11,13]
I know its really simple, but I'm really new to this and I'd really
appreciate some help.
Thanks!
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Tutor
mailing list