[Tutor] example help

arkamir at softhome.net arkamir at softhome.net
Fri Aug 8 11:27:29 EDT 2003


Hey im knew to programing and i got these examples out of the book THE QUICK 
PYTHON GUIDE. I understand all the other examples but these 2 just stump me. 
Can anyone help explain them to me?? 

This example gives the factorial of a number 

def fact(n):
  r=1
  while n >0:
     r=r*n
     n=n-1
  return r 

This one calculates a number (x) to a number (Y) which has an initial 
setting to 2 

def power(x, y=2):
  r=1
  while y>0:
     r=r*x
     y=y-1
  return r
thanks 



More information about the Tutor mailing list