Parameters and Arguments

Parameters 和 Arguments 这两个单词翻译过来都是参数,我一直都挺疑惑他们之间有什么区别。细看了一下,原来就是形参和实参,函数定义处的参数为形参,而函数被调用的地方叫实参。

# Function definition with parameters
def add(x, y):  # x and y are parameters
    return x + y

# Calling the function with arguments
result = add(5, 3)  # 5 and 3 are arguments

# Display the result
print(f"Result of adding 5 and 3 is: {result}")


还是多看看英文文档,有些不必要的疑惑就能更早的消除了。不然也不会到今天才将这两组词语关联起来。

Difference Between Parameters and Arguments - GeeksforGeeks

#til
 
 
Back to Top