python学習4番目の関数
1156 ワード
#!/usr/bin/env python
#coding:utf-8
# : , , ,
# : def , ()
# ,
# , 。
#return( ) , 。
#
def hello(name):
print "hello %s" %(name)
hello(name="fujinzhou")
hello(name="reboot")
#
#
def prininfo(arg1,*vartuple):
print " :"
print arg1
print vartuple
return
prininfo(10,20,30,40)
# lambda
#lambda [arg1 [,arg2,.....argn]]:
#
sum1=lambda arg1,arg2:arg1*arg2
# sum1
print " :",sum1(10,29)
#return
#return [ ] , 。 return None。
#
def count(arg1,arg2):
total=arg1+arg2
print " :",total
return total
# count
total=count(10,20)
print " :",total
# 。
#
# ,
# ,
#
total=0
def sum(arg1,arg2):
total=arg1+arg2
print " :",total
return total
sum(10,20)
print " :",total