How do you define a function, and what are default arguments?

Python control flow and functions · Freshers

Model answer

def greet(name, greeting="Hello"): return f"{greeting}, {name}". A default is used when the caller does not pass that argument. Parameters with defaults must come after those without.

Learn this topic

Functions in Python: def, Arguments and return in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions