“打电话"是什么意思?Python 中的函数? [英] What does it mean to "call" a function in Python?
本文介绍了“打电话"是什么意思?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
你会像这样调用函数:
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)
在这种情况下,这会将变量 answer 设置为等于 11.
Which would set the variable answer equal to 11 in this case.
这篇关于“打电话"是什么意思?Python 中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文