Arguments are the values passed to a function when it is called. They allow functions to work with dynamic input instead of fixed values.
Python
def greet(name): print("Hello", name) greet("Rahul") #output 'Hello Rahul' name -> parameter
"Rahul" -> Argument
Parameter vs Arguments :
A parameter is the variable listed inside the parentheses in the function definition.
An argument is the actual value that is sent to the function when it is called.
Types of Function Arguments :
1. Positional Arguments :
Values are passed in the same order as parameters. Order is Important here.
Python
def add(a, b): print(a + b) add(5, 10) #output 15 2. Keyword Arguments :
Arguments are passed using parameter names.
Python
def student(name, age): print(name, age) student(age=22, name="Rahul") #output Rahul 22 3. Default Arguments :
If no value is passed → default value is used.
Python
def greet(name="User"): print("Hello", name) greet() greet("Rahul") #output Hello User Hello Rahul