+ 1
What are arguments in Python?
2 Answers
+ 2
def add(x,y):
return x+y
add(4,3)
The top is a simple function that takes 2 arguments. An x value and a y value.
The bottom is calling that function. Notice when I call the add() function I am calling it with two integers. a 4 and a 3. When the function runs, it assigns the arguments 4 and 3 to the x and y variables
+ 2
An argument is any value given to a variable when a function is called. Here's an example:
def mult(x,y):
return x * y
print(mult(5,3))
In that example, 5 and 3 would be the arguments passed through the function mult.
Hope this helped! d: