参数
作者:互联网
#参数 # def len_func(s): #形参 # count=0 # for i in s: # count+=1 # return count # # str1=input('>>>') # str2=input('>>>') # ret1=len_func(str1) #实参 # ret2=len_func(str2) # print(ret1) # print(ret2) #写一个sum_func函数,求和 # def sum_func(a,b,c): # return a+b+c # ret=sum_func(1,2,3) # print(ret) #写一个函数,传入2个参数,比较2个参数的大小,返回比较大的一个数值 # def max(a,b): # if a>b: # return a # else: # return b # # ret=max(12,34) # print(ret) #为什么写返回值 可以比较 # def len_func(s): # count = 0 # for i in s: # count+=1 # print(count) # # s1='hello' # s2='wind' # ret1=len_func(s1) # ret2=len_func(s2) # print(ret1) #返回none # print(ret2) # print(ret1>ret2)#报错 def len_func(s): count = 0 for i in s: count+=1 return count s1='hello' s2='wind' ret1=len_func(s1) ret2=len_func(s2) print(ret1>ret2) #True
标签:count,len,ret2,ret1,参数,func,print 来源: https://www.cnblogs.com/gm11/p/16414215.html