Functions · Python example
Define a reusable greeting function with a default parameter value.
Functions bundle logic behind a name. Default arguments make some parameters optional, which keeps calls short.
def greet(name, greeting="Hello"):
return f"{greeting}, {name}!"
print(greet("Ada"))
print(greet("Grace", "Welcome"))