What are “arguments” in python

An argument is simply a value provided to a function when you call it:

x = foo( 3 )         # 3 is the argument for foo
y = bar( 4, "str" )  # 4 and "str" are the two arguments for bar

Arguments are usually contrasted with parameters, which are names used to specify what arguments a function will need when it is called. When a function is called, each parameter is assigned one of the argument values.

# foo has two named parameters, x and y
def foo ( x, y ):
    return x + y

z = foo( 3, 6 )

foo is given two arguments, 3 and 6. The first argument is assigned to the first parameter, x. The second argument is assigned to the second parameter, y.

Leave a Comment