Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Functions in python
  5. Function arguments

Function arguments

The Parameter list are placeholders that define the parameters that go into the function. In python, parameters are enclosed in parentheses.

The Argument in programming is the value that we supply to a function when we call function.

Arguments are specified after the function name, inside the parentheses.

We can pass as many arguments as we want from a function.

syntax:-

def function_name(parameter)
    body of function
function_name(argument)

The Number of parameter should be equal to the number of arguments.

e.g.,

def greet_user(name)
    print(f'Hi {name}')
greet_user("Mary")
Output- Hi Mary

We can also set a default value for an argument.

We assign a default value to an argument using the assignment operator in python(=). When we call a function without a value for an argument, its default value (as mentioned) is used.

e.g.,

def greet_user(name="John"):
    print(f'Hi {name}')
greet_user()
Output- Hi John

This is all about function arguments in python.

Was this article helpful to you? Yes No

How can we help?