Function Arguments
Use the full potential of Python functions. Learn about different ways to declare, call, and interact with functions!
StartKey Concepts
Review core concepts you need to learn to master this subject
Default argument is fallback value
Mutable Default Arguments
Python Default Arguments
Python function default return value
Python variable None check
Python function arguments
Default argument is fallback value
Default argument is fallback value
def greet(name, msg="How do you do?"):
print("Hello ", name + ', ' + msg)
greet("Ankit")
greet("Ankit", "How do you do?")
"""
this code will print the following for both the calls -
`Hello Ankit, How do you do?`
"""
In Python, a default parameter is defined with a fallback value as a default argument. Such parameters are optional during a function call. If no argument is provided, the default value is used, and if an argument is provided, it will overwrite the default value.
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory