Skip to content
Guest
Learn Python · Course Syllabus Show lessons
Functions & Data · 8 min read · Beginner

Functions & Default Arguments

Package reusable logic with def, default parameter values, keyword arguments, and return statements.

What you'll learn

  • Define clean functions using def and return
  • Provide sensible default argument values
  • Call functions with keyword arguments for readability

Functions in Python start with the def keyword and return values with return.

def calculate_percent(done, total, decimals=0):
    ratio = (done / total) * 100
    return round(ratio, decimals)

Fill-in-the-Blank Exercise

Define a Python Function

Declare a greet function with a default name of 'World' and return the f-string.

 greet(name="World"):
   f"Hello, {name}!"

Try It Yourself

PythonReusable Functions & Keyword Arguments
Python Output (WebAssembly / Pyodide)

Click Run Python to execute real Python 3 right in your browser.

Check Your Understanding

Score: 0 / 1

1. What does a Python function return if it has no return statement?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind