这对于“呼叫”来说意味着什么? Python中的函数? [英] What does it mean to "call" a function in Python?

查看:115
本文介绍了这对于“呼叫”来说意味着什么? Python中的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

电话意味着什么?如何在Python中调用函数?

What does "call" mean and do? How would you "call" a function in Python?

推荐答案

当你调用一个函数时,你基本上只是告诉程序执行该功能。所以,如果你有一个函数添加了两个数字,例如:

When you "call" a function you are basically just telling the program to execute that function. So if you had a function that added two numbers such as:

def add(a,b):
    return a + b

你可以这样调用函数:

you would call the function like this:

add(3,5)

其中将返回8.在这种情况下,您可以将任何两个数字放在括号中。你也可以调用这样的函数:

which would return 8. You can put any two numbers in the parentheses in this case. You can also call a function like this:

answer = add(4,7)

在这种情况下,将变量答案设置为11。

Which would set the variable answer equal to 11 in this case.

这篇关于这对于“呼叫”来说意味着什么? Python中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆