python的参数分类 python参数可以分为两类:1.定义时的参数--形参(形式参数).2.调用时的参数--实参(实际参数,传参) 实参的规则 实参就是在函数调用的时候,通过函数后面的括号传递给函数,让函数处理的值,如下: def factorial(x, y): # 定义一个factorial函数,设置两个形参 """ This is a function that can calculate the product of the two parameter that
1.函数 def my_len(): l = [,,,,,,] count = for i in l: count += print(count) my_len() 定义的my_len()方法时,其结果也可以直接获取. 这里,我们将my_len()称为执行函数,其组成是由 :函数名(). 函数的优点: 1. 函数可以减少代码的重复性 2. 函数可以增强代码的阅读性 2.return的作用 def func1(): a = b = c = a + b return c print(func1())