| ¥Û¡¼¥à¡¡¡¡¡¡¡¡¡¡Ìá¤ë     Ì´¡¡
 ¾®½®¤¬°ìçÛ¡¡²Æ¶õ¤Ë
 ¡¡¡¡Ì´¸«¿´ÃϤˤ¿¤æ¤¿¤¤¤Æ
 ¡¡¡¡¤¢¤ë7·î¤ÎÃë²¼¤¬¤ê
 ¡¡ÉԻ׵Ĥιñ¤Ë¤Þ¤É¤í¤ß¤Æ
 ¡¡Æü¡¹¤Î¤Þ¤Ë¤Þ¤ËÌ´¤ò¸«¤ë
 ¡¡À¤¯²Æ¤Î¤è¤¦¤ËÌ´¤ò¸«¤ë
 ¡¡Î®¤ì¤Ë±è¤Ã¤ÆÎ®¤µ¤ì¤Æ¡¡¶â¤Î¸÷¤Ë¤¿¤æ¤¿¤¤¤Æ
 ¡¡¿ÍÀ¸¡¢¤½¤ì¤Ï¤¿¤À¤ÎÌ´
 ¡Ê¥¥ä¥í¥ë¡Ë
 
 20110923¹¹¿· ¡¡Â裱£°¾Ï¡¡ºÆµ¢¤È¤³¤ì¤Þ¤Ç¤ÎÉü½¬
  def hello():            <function  identfier:hello:nameprint("hello")
   >>> hello()          < function callhello
 >>> res=hello()     <procdure
 hello
 
 >>> print(res)     < return None
 None
 >>> print(hello())hello
 None
  def foo():return ["xyz",1000000,-98.6]
 def bar ():
 return ("abc",[42,"python"],"guido")
  >>> atuple=bar()           # assignment>>> x,y,z = bar()
 >>> (a,b,c) = bar()
 >>> atuple
 ('abc', [42, 'python'], 'guido')
 >>> x,y,z
 ('abc', [42, 'python'], 'guido')
 >>> (a,b,c)
 ('abc', [42, 'python'], 'guido')
 >>> foo()
 ['xyz', 1000000, -98.6]
 >>> a= foo()
 >>> a
 ['xyz', 1000000, -98.6]
 >>> bar()
 ('abc', [42, 'python'], 'guido')
 >>> b= bar()
 >>> b
 ('abc', [42, 'python'], 'guido')
 >>>
 
 ¡¡ög´Ø¿ô¤¬ÆâÉô¤Ç¼«Ê¬¼«¿È¤ò»²¾È¤·¸Æ¤Ó½Ð¤¹¤³¤È¤ò¡ÖºÆµ¢¸Æ¤Ó½Ð¤·¡×¤È¤¤¤¦¡£ºÆ
 µ¢¤ò»È¤¦¤³¤È¤Ç£æ£ï£ò¤ä£÷£è£é£ì£å¤ò»È¤ï ¤Ê¤¤¤Ç·«¤êÊÖ¤·¤ò¼Â¹Ô¤¹¤ë¡£
 ¡¡def displayްrange(lower,upper):¡¡ while lower <= upper:          < ·«¤êÊÖ¤·¼Â¹Ô¤¹¤ë¥Ü¥Ç¥¤
 ¡¡print(lower)
 ¡¡lower=lower+1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡<¡¡£Ì£Ï£×£Å£Ò¤Î¤ß¡Ü£±¤¹¤ë
 ¡¡>>> displayްrange(1,5)¡¡1
 ¡¡2
 ¡¡3
 ¡¡4
 ¡¡5
 ¡¡def displayްrange(lower,upper):¡¡if lower <= upper :
 ¡¡print(lower)
 ¡¡displayްrange(lower + 1,upper)
   ¡¡>>> displayްrange(6,10)
 ¡¡6
 ¡¡7
 ¡¡8
 ¡¡9
 ¡¡10
 
 ¡¡>>> def fact(n):¡¡¡¡¡¡¡¡¡¡ re=n
 ¡¡¡¡¡¡¡¡¡¡for i in range(1,n):
 ¡¡¡¡¡¡¡¡¡¡¡¡¡¡re *=i
 ¡¡¡¡¡¡¡¡¡¡return re
 ¡¡>>> fact(1)¡¡1
 ¡¡>>> fact(2)
 ¡¡2
 ¡¡>>> fact(3)
 ¡¡6
 ¡¡>>> fact(4)
 ¡¡24
 ¡¡>>> fact(5)
 ¡¡120
 
 ¡¡>>> def fact(n):
 ¡¡if n==1:
 ¡¡return 1
 ¡¡else:
 ¡¡return n * fact(n-1)
  ¡¡>>> fact(1)
 ¡¡1
 ¡¡>>> fact(2)
 ¡¡2
 ¡¡>>> fact(3)
 ¡¡6
 ¡¡>>> fact(4)
 ¡¡24
 ¡¡>>> fact(5)
 ¡¡120
 ¡¡>>> def fact(x):¡¡¡¡¡¡¡¡¡¡¡¡if x<=1:¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ºÆµ¢¾ò·ï
 ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡return 1¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£±¤òÊÖ¤·ºÆµ¢¤Ïµ¯¤¤Ê¤¤
 ¡¡¡¡¡¡¡¡¡¡¡¡return x*fact(x-1)¡¡¡¡¡¡¡¡¡¡¡¡£æ£á£ã£ô´Ø¿ô¤¬¼«Ê¬¼«¿È¤ò¸Æ¤Ó
 ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡½Ð¤¹
 >>> fact(100)93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
 >>>
 
 ¡¡¥á¥½¥Ã¥É¤Îºî¤êÊý¡¡def¡¡´û½¬
 ¡¡¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·Êý¡¡fact()¡¡¡¡´û½¬
 ¡¡ºÆµ¢recursion:¼«Ê¬¼«¿È¤ò¸Æ¤Ó½Ð¤¹¥á¥½¥Ã¥É¤òºî¤ë¡¡³Ø½¬
 
 ¡¡ºÆµ¢¤ÎÎã   ¡¡³¬¾è ¡¡0! = 1
¡¡n! = n * (n - 1)! ¡¡³¬¾è¤ÎÄêµÁ¡¡¼«Á³¿ô ![[n]](http://www.suriken.com/knowledge/glossary/img/glossary_scheme_298.gif) ¤ËÂФ·¤Æ¡¢ 1¤«¤é ![[n]](http://www.suriken.com/knowledge/glossary/img/glossary_scheme_298.gif) ¤Þ¤Ç¤Î¤¹¤Ù¤Æ¤Î ¼«Á³¿ô¤ò¾è¤¸¤¿¤â¤Î¤ò ![[n]](http://www.suriken.com/knowledge/glossary/img/glossary_scheme_298.gif) ¤Î³¬¾è¤È¤¤¤¤¡¢ ![[n!]](http://www.suriken.com/knowledge/glossary/img/glossary_scheme_299.gif) ¤Èɽ¤¹¡£ ¡¡Î㤨¤Ð¡¢5¤Î³¬¾è¤Ï
 
 ¡¡5!=1*2*3*4*5=120  ºÆµ¢¤ò¤Ä¤«¤Ã¤Æ¥×¥í¥°¥é¥à¤òºî¤ë¡£fact(n-1)¡¡def fact(n): ¡¡if n == 0: return 1
 ¡¡return n * fact(n - 1)
 ¡¡>>> fact(0)
 ¡¡1
 ¡¡>>> fact(1)
 ¡¡1
 ¡¡>>> fact(2)
 ¡¡2
 ¡¡>>> fact(3)
 ¡¡6
 ¡¡>>> fact(4)
 ¡¡24
 ¡¡>>> fact(5)
 ¡¡120
  ¡Ê£±¡ËÁ°¾Ï¤Î¿´Íý¥Æ¥¹¥È¤Î£á£ó£ë¥á¥½¥Ã¥É¤Îwhile¥ë¡¼¥×¤òºÆµ¢¤ÇÃÖ¤´¹¤¨¤ë¡£ ¡¡>>> def ask_recursively():¡¡¡¡¡¡¡¡print('q1')
 ¡¡¡¡¡¡¡¡reply=input('"yes"¤«"no"¤Ç¤ªÅú¤¨¤¯¤À¤µ¤¤¡£¡ä¡ä')
 ¡¡¡¡if reply =='yes':
 ¡¡¡¡¡¡¡¡True
 ¡¡¡¡elif reply=='no':
 ¡¡¡¡¡¡¡¡False
 ¡¡¡¡ else :
 ¡¡¡¡¡¡¡¡ print( '"yes"¤«"no"¤Ç¤ªÅú¤¨¤¯¤À¤µ¤¤¡£')
 ¡¡ask_recursively()
   ¡¡>>> ask_recursively()
 ¡¡q1
 ¡¡"yes"¤«"no"¤Ç¤ªÅú¤¨¤¯¤À¤µ¤¤¡£¡ä¡äyes
 ¡¡>>> ask_recursively()
 ¡¡q1
 ¡¡"yes"¤«"no"¤Ç¤ªÅú¤¨¤¯¤À¤µ¤¤¡£¡ä¡äno
 ¡¡>>> ask_recursively()
 ¡¡q1
 
  ºÆµ¢¸Æ¤Ó½Ð¤·¤¬½ªÎ»¤¹¤ë¡£ ¡¡¡¡>>> def example(n):if n > 0:
 print(n)
 example(n-1)
   >>> example(10)
 10
 9
 8
 7
 6
 5
 4
 3
 2
 1
 ¡¡>>> def power(x,n):
 if n==0:
 return 1
 else :
 return x*power(x,n-1)
  >>> power(3,3)27¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
 
  Îý½¬£±¡¡ºÆµ¢¤ò»È¤ï¤Ê¤¤¤Ç³¬¾è¤Î¥×¥í¥°¥é¥à¤ò¤Ä¤¯¤ë¡£¡¡¡¡¡¡¡¡¡¡¡¡£±¤«¤é£î¤Þ¤Ç¤Î¤¹¤Ù¤Æ¤Î¿ô»ú¤ò´Þ¤à¥ê¥¹¥È¤ò¥ë¡¼¥×¤ò½èÍý¤··«¤êÊÖ¤·¼Â¹Ô¤Î¤¿
 ¤Ó¤Ë¸½ºß¤Î¹ç·×¤È¸½ºß¤Î¹àÌܤò³Ý¤±¤ë. ¡ÊÉÕÏ¿ÊÔ¤ËÅú°Æ¤¢¤ê¡Ë
 ¥Û¡¼¥à¡¡¡¡¡¡¡¡¡¡Ìá¤ë |