#len
# s = ' King boss ' little Nurse '
# len (s)
# def My_len (): #自定义函数
# i = 0
# for K in S:
# i + = 1
# Print (i)
#
# length = My_len ()
# print (length)
# function
# once defined, it can be called wherever it is needed
# no return length, just simple print
#返回的重要性
#a, b
#len (a) #内置函数
#len (b)
# def My_len (): #自定义函数
# i = 0
# for K in S:
# i + = 1
# return I #返回值
#
# length = My_len ()
# print (length)
#len ()
#1. Cannot be changed, only the length of s string can be computed
#2. Just output the results.
#返回值
#返回值的3种情况
# no return value--return None
# Don't write return
# write only return: End the continuation of a function
# return none--not used
# returns 1 values
# can return any data type
# Just go back and you can get it
# If there are multiple return in a program, only the first one is executed
# returns multiple values
# Receive with multiple variables: How many variables are received with the number of return values
# received with a variable: a tuple is obtained
# def func ():
# l = [' King boss ', ' second brother ']
# for I in L:
# Print (i)
# if i== ' Gold boss ':
# return None
# print (' = ' *10)
# ret = func ()
# Print (ret)
# def func ():
# return {' K ': ' V '}
# Print (func ())
# def FUNC2 ():
# return #return
#
# r= Func2 ()
# print (R)
# def My_len (s): #自定义函数只需要0个参数, receive parameters, formal parameters, formal parameter
# i = 0
# for K in S:
# i + = 1
# return I #返回值
#
# ret = My_len (' King boss Little Nurse ') #传递参数: parameters, actual arguments, arguments
# ret = My_len ([1,2,3,4,5]) #传递参数: Parameter transfer
# Print (ret)
#什么叫参数?
#参数的语法
#形参和实参的概念
# def F2 (L1):
# f1 (L1)
# for I in L1:
# Print (i)
#
# def F1 (L1):
# for I in L1:
# Print (i)
#
# F2 ([1,2,3,4])
#参数
#没有参数
#定义函数和调用函数时括号里都不写内容
#有一个参数
#传什么就是什么
#有多个参数
#位置参数
# def my_sum (A, B):
# print (A, B)
# res = A+b #result
# return Res
#
# ret = My_sum
# Print (ret)
#站在实参的角度上:
#按照位置传参
#按照关键字传参
#混着用可以: However, you must first pass the parameter by location and then pass the key
# cannot pass multiple values to the same variable
#站在形参的角度上
#位置参数: Must pass, and have several parameters to pass several values
#默认参数: Can not preach, if not pass is the default parameters, if the transmission of the
# def classmate (name,sex= ' man '):
# print ('%s:%s '% (name,sex))
#
# classmate (' second brother ')
# classmate (' Xiao Meng ')
# classmate (' Big Bang ')
# classmate (' Valter ', ' female ')
#只有调用函数的时候
#按照位置传: The value of the direct write parameter
#按照关键字: keyword = value
#定义函数的时候:
#位置参数: Defining parameters directly
#默认参数, keyword argument: parameter name = ' Default value '
#动态参数: can accept any number of parameters
#参数名之前加 *, custom parameter name args,
#参数名之前加 * *, custom parameter name Kwargs
#顺序: Positional parameters, *args, default parameters, **kwargs
# def classmate (Name,sex):
# print ('%s:%s '% (name,sex))
#
# classmate (' second brother ', ' male ')
# classmate (sex= ' man ', name = ' two elder brother ')
# def classmate (name,sex= ' man '):
# print ('%s:%s '% (name,sex))
#
# classmate (' second brother ')
# classmate (' Valter ', sex= ' women ')
# def sum (*args):
# n = 0
# for I in args:
# n+=i
# return N
#
# Print (SUM)
# Print (sum ())
# Print (sum (1,2,3,4))
# def func (**kwargs):
# Print (Kwargs)
#
# func (a = 1,b = 2,c =3)
# func (a = 1,b = 2)
# func (A = 1)
# There are two types of dynamic parameters: one can accept any parameter
#*args: Received by the value of the location parameter, organized into a tuple
#**kwargs: Accept the value of the key parameter, organized into a dictionary
#args必须在kwargs之前
# def func (*args,default = 1,**kwargs):
# Print (Args,kwargs)
#
# func (1,2,3,4,5,default=2,a = ' AAAA ', B = ' bbbb ',)
#动态参数的另一种传参方式
# def func (*args): #站在形参的角度上, adding * to the variable, is the combination of all the transmitted values.
# print (args)
#
# func (1,2,3,4,5)
# l = [1,2,3,4,5]
# func (*l) #站在实参的角度上, adding * to a sequence, is to break the sequence in order
# def func (**kwargs):
# Print (Kwargs)
#
# func (a=1,b=2)
# d = {' A ': 1, ' B ': 2} #定义一个字典d
# func (**d)
#函数的注释
# def func ():
# ‘‘‘
# What functions this function implements
# parameter 1:
# parameter 2:
#: Return: Is the string or the length of the list
# ‘‘‘
# Pass
# Default parameters for traps
# Changes to Files
# function
#1. Definition of function def
#2. Calls to Functions
#3. return value of function
#4. Parameters of a function
#形参:
# positional parameters: must be passed
# *args: Can receive any number of positional parameters
# default parameter: Can not pass
# **kwargs: Can receive multiple keyword parameters
#实参: According to the location of the parameter, according to the key word
#函数
#内置函数
#自定义函数!!!!!
Python learns the first Nineth day function