def greet(name="friend"):
print(f"Hello, {name}")Line-by-line explanation
- The function has one parameter.
="friend"gives it a default.- The body displays the selected name.
greet()Line-by-line explanation
- The call provides no name.
- Python uses friend.
- The output is
Hello, friend.
greet("Maya")Line-by-line explanation
- The call provides Maya.
- Maya replaces the default for this call.
- The output is
Hello, Maya.