Terms |
Definitions |
Examples |
Default Arguments |
Values that are set in the function definition and used if no argument value is passed during the function call. |
def greet(name="User"):
print(f"Hello, {name}")
greet() # Outputs: Hello, User
greet("Alice") # Outputs: Hello, Alice
|
Keyword Arguments |
Arguments that are identified by their parameter name when passed during a function call. This helps to make the code more readable. |
def greet(greeting, name):
print(f"{greeting}, {name}")
greet(greeting="Hi", name="Bob") # Outputs: Hi, Bob
|
Arguments |
The actual values that are passed to a function when it is invoked/called. |
def add(a, b):
return a + b
print(add(3, 4)) # Outputs: 7
|
Parameters |
Variables used in function definitions to represent the values that will be passed to the function. |
def add(a, b): # 'a' and 'b' are parameters
return a + b
|