0Pricing
Python Academy · Lesson

Default and Keyword Arguments

Use default parameter values and keyword call syntax.

Introduction

Default parameter values and keyword call syntax make Python functions flexible and self-documenting.

Default Parameter Values

def greet(name, greeting='Hello'): gives greeting a default. Callers can omit it.
def greet(name, greeting='Hello'):
    print(f'{greeting}, {name}!')
greet('Alice')
greet('Bob', 'Hi')

All lessons in this course

  1. Defining and Calling Functions
  2. Default and Keyword Arguments
  3. args and kwargs
  4. Return Values and Scope
← Back to Python Academy