python调用带参函数_Python | 带有示例的函数调用类型

python调用带参函数

There are following types of function calls in python:

python中有以下类型的函数调用:

  1. Call by value

    按价值致电

  2. Call by reference

    通过参考电话

1)按价值致电 (1) Call by value )

When, we call a function with the values i.e. pass the variables (not their references), the values of the passing arguments cannot be changes inside the function.

当我们调用带有值的函数时,即传递变量(而不是它们的引用)时,传递的参数的值不能在函数内部更改。

# call by value 
def change(data):
    data=45
    print("Inside Function :",data)

def main():
    data=20
    print("Before Calling  :",data)
    change(data)
    print("After  Calling  :", data)

if __name__=="__main__":main()

Output

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值